0

I want to fetch a single column into an array. I am using following code

TYPE t_column IS TABLE OF TABLE_1.COLUMN_1%TYPE INDEX BY PLS_INTEGER;
ar_column t_column;

Then the query is something like

select column_1 from table_1 where column_1 = values;

And i am trying to fetch it

OPEN cr_table FOR select_query;
LOOP
    FETCH cr_table INTO ar_column LIMIT 1000;
    EXIT WHEN ar_column.count = 0
END LOOP;

But for this i am getting error Error(1526,25): PLS-00597: expression 'ar_column' in the INTO list is of wrong type

Em Ae
  • 8,167
  • 27
  • 95
  • 162
  • Never mind, I figure out the mistake. I was suppose to use BULK COLLECT INTO. Can someone close the question ? – Em Ae Jan 08 '14 at 22:58
  • I can only look at this and think, "What? Why?" Of course, I must also consider the possibility that the answer is, "Because Oracle." (I've been there plenty of times myself, after all.) – jpmc26 Jan 09 '14 at 04:40

1 Answers1

0

try this:

declare

cursor c1 is

select last_name ls from empc;

type x is table of employees.last_name%type;

x1 x := x();

cnt integer :=0;

begin

for z in c1 loop 

cnt := cnt +1;

exit when cnt > 5;

x1.extend;

x1(cnt) := z.ls;

dbms_output.put_line(cnt || ' '|| x1(cnt));

end loop;

end;
Nagaraj S
  • 13,316
  • 6
  • 32
  • 53
Ashish sinha
  • 148
  • 2
  • 9