用cursor。
open cursor for vSql using vDw;

解决方案 »

  1.   

    然后
    loop
     fetch yourcursor into iCount,vFlbh;
     exit when yourcursor%notfound;
     ....insert操作
    end loop;
      

  2.   

    表结构相同的话直接这样写:SQL> DECLARE
      2  BEGIN
      3    EXECUTE IMMEDIATE 'insert into dd select * from aa';
      4  END;
      5  /PL/SQL 过程成功完成SQL> commit;提交完成SQL> select * from dd;        ID         LJ Y
    ---------- ---------- -----------
             1          2 2005-8-1
             3          5 2005-8-4
             1          2 2005-8-1
             3          5 2005-8-4SQL>
      

  3.   

    iCount int;
    vFlbh varchar2(2);
    ...
    vSql:='insert into <tablename> select t.qxflbh,count(*) from mytable t where t.qxdjrdw=:vDw group by t.qxflbh';
    Execute Immediate vSql ;
      

  4.   

    加上ding定义申明:
          
    type t_Cursor is REF CURSOR;
          qxCursor t_Cursor;