Reputation: 1235
declare
v_tx varchar2(100);
type myarray is table of EMP%ROWTYPE;
rec_a myarray;
begin
v_tx := 'SELECT * FROM EMP';
execute immediate v_tx
into rec_a;
FOR C in 1 .. rec_a.COUNT
LOOP
DBMS_output.put_line(rec_a.ename(C));
END LOOP;
end;
I cant pinpoint the error in it, any help would be very much appreciated.
Upvotes: 0
Views: 40
Reputation: 30765
Your code has two errors:
rec_a.ename(C)
, you have to use rec_a(C).ename
The fixed query is:
declare
v_tx varchar2(100);
type myarray is table of EMP%ROWTYPE;
rec_a myarray;
begin
v_tx := 'SELECT * FROM EMP';
execute immediate v_tx bulk collect
into rec_a;
FOR C in 1 .. rec_a.COUNT
LOOP
DBMS_output.put_line(rec_a(C).ename);
END LOOP;
end;
Upvotes: 2