Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fetch a cursor into array

I have a table with numerical values and I want to fetch that values into an array. Can I do that? Is there a function that allows me to do this? I am relatively new to pl/sql and I don't know. Thanks!

like image 310
katy Avatar asked Sep 24 '26 22:09

katy


1 Answers

set serveroutput on;
DECLARE
TYPE v_arr IS VARRAY(100) OF NUMBER;
var v_arr;
return_value number;
BEGIN
var:=v_arr();
FOR c1 IN (SELECT ID FROM table_name WHERE ROWNUM<100)
loop
var.EXTEND;
var(var.last):=c1.id;
end loop;

FOR i IN var.FIRST..var.LAST
loop
return_value:=var(i);
dbms_output.put_line(return_value);
end loop;
end;
like image 61
Sandeep Avatar answered Sep 27 '26 18:09

Sandeep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!