Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

bulk collect and variables(how to create runtime variable)

ShackirMar 7 2012 — edited Mar 8 2012
Hi friends,

I'm trying to use bulk collect instead of Cursor in my PLSQL block, But i'm facing one problem that the size of variable. Becuase the variable size must be given at the time of Compilation. where I need to give the size dynamically at runtime.. There is any other variable/or other way to solve this problem.

For Eg:-
declare
type my_arr is varray(100) of number;
lv_arr my_arr;
begin
select eno bulk collect into lv_arr from emp;
end;

Here array size is 100 and is fixed. But in my table i'm having more than 100 will give error. So i need to use any other variable which can hold unlimited values. My requirement is like this

1. First i will find the count of records from my table.
2. Based on this value i need to create a new variable to hold all the values. So it will not raise any error


Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 5 2012
Added on Mar 7 2012
12 comments
1,130 views