oracle 简单存储 一个表的数据转入另外的表


线损统计导入

select * from xs_gz t order by to_number(t.gz_num) asc

declare
j number:=0;
i number:=0;
k number:=0;
begin
select max(to_number(id)) into j from xs_gz;
select max(to_number(gz_num)) into i from xs_gz;
select max(to_number(id)) into k from xs_gzbj;
for cr in ( select t.* from qw_dr_temp t) loop
j:=j+1;
i:=i+1;
k:=k+1;
insert into xs_gz (id,gz_num,gl_org,gl_orgname,tj_lb,tj_lbname,tj_kj,tj_kjname,pq_mc,tj_mc,tj_xl,tj_xlname)
values(j,CONCAT('00000',i),'511104',cr.f1,'01','供售电量','01','区域',cr.f2,cr.f2,'导入统计',cr.f7);
dbms_output.put_line(j);
dbms_output.put_line( CONCAT('00000',i));

insert into xs_gzbj (id,gz_num,AZWZ,bjmc,mjh,zf,tj_xlname)
values(k,CONCAT('00000',i),'',cr.f2,cr.f5,cr.f6,'供电量');


end loop;
end;

你可能感兴趣的:(数据库)