然后 loop fetch yourcursor into iCount,vFlbh; exit when yourcursor%notfound; ....insert操作 end loop;
表结构相同的话直接这样写: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>
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 ;
loop
fetch yourcursor into iCount,vFlbh;
exit when yourcursor%notfound;
....insert操作
end loop;
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>
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 ;
type t_Cursor is REF CURSOR;
qxCursor t_Cursor;