执行立即返回多个记录

时间:2011-05-29 13:32:39

标签: sql database oracle plsql

  

可能重复:
  EXECUTE IMMEDIATE in plsql

假设我不知道动态sql会返回哪些字段,我不能去r.columna,r.columnb.etc?

我正在尝试从执行立即打印出多个记录。 这就是我所拥有的:

DECLARE
 VTABLE VARCHAR2(30);
SQLS  VARCHAR2(1000);
BEGIN
  select cola INTO VTABLE
  FROM tablea
  WHERE ROWNUM < 2;
SQLS := 'select id, width, height, volume, area, price from '||VTABLE;

  EXECUTE IMMEDIATE SQLS  BULK COLLECT INTO RESULTs;
  DBMS_OUTPUT.PUT_LINE('i want to print all the records returned from the dynamic sql query above here');
END;

0 个答案:

没有答案