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;
我无法确定其中的错误,我们非常感谢任何帮助。
答案 0 :(得分:2)
您的代码有两个错误:
rec_a.ename(C)
,你必须使用rec_a(C).ename
固定查询是:
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;