declare
-- Local variables here
i integer;
cursor c_province is select ds.swjg_dm from dm_swjg ds where ds.swjg_dm!=0;
cursor c_year is select distinct yh.tjyf from ygz_hs yh where yh.tjyf like '2013%' group by yh.tjyf;
begin
-- Test statements here
i:=0;
for cp in c_province loop
for cy in c_year loop
i:=i+1;
--dbms_output.put_line('i='||i||'=='||cp.swjg_dm||cy.tjyf); -------------输出结果集
insert into ygz_hs values (cp.swjg_dm,cy.tjyf,'15000','15000','小规模纳税人');
end loop c_year;
end loop c_province;
end;
一条SQL搞不掂的时候,要考虑循环游标的使用。
oracle可以做很多事情,多尝试,多动脑就会有很大的收货。