create or replace procedure pub_obt_trans_prc is
msgout varchar2(600);
lasttime date;
CURSOR cur_datalist IS
select * from test
begin
for rec in cur_datalist loop
---------test表转储表到testa和testb两张表
insert into testa(test1,test2)
values
(rec.test1,rec.test2);
insert into testb(test3,test4)
values
lasttime :=rec.datetime;
end loop;
-----写日志
if(lasttime IS null) Then
INSERT INTO PUB_DATATRANS_LOG(DATAID,DATANAME,TRANSTIME,DATATIME,LOG)
VALUES('1','1',SYSDATE,lasttime,'NO DATA');
Else
INSERT INTO PUB_DATATRANS_LOG(DATAID,DATANAME,TRANSTIME,DATATIME,LOG)
VALUES('1','1',SYSDATE,lasttime,'OK');
END if;
commit;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
msgout := 'pub_obt_trans_prc' || SUBSTR(SQLERRM,1,500);
INSERT INTO PUB_DATATRANS_LOG(DATAID,DATANAME,TRANSTIME,DATATIME,LOG)
VALUES('','58237',SYSDATE,lasttime,msgout);
COMMIT;
end pub_obt_trans_prc;
msgout varchar2(600);
lasttime date;
CURSOR cur_datalist IS
select * from test
begin
for rec in cur_datalist loop
---------test表转储表到testa和testb两张表
insert into testa(test1,test2)
values
(rec.test1,rec.test2);
insert into testb(test3,test4)
values
(rec.test3,rec.test4);
lasttime :=rec.datetime;
end loop;
-----写日志
if(lasttime IS null) Then
INSERT INTO PUB_DATATRANS_LOG(DATAID,DATANAME,TRANSTIME,DATATIME,LOG)
VALUES('1','1',SYSDATE,lasttime,'NO DATA');
Else
INSERT INTO PUB_DATATRANS_LOG(DATAID,DATANAME,TRANSTIME,DATATIME,LOG)
VALUES('1','1',SYSDATE,lasttime,'OK');
END if;
commit;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
msgout := 'pub_obt_trans_prc' || SUBSTR(SQLERRM,1,500);
INSERT INTO PUB_DATATRANS_LOG(DATAID,DATANAME,TRANSTIME,DATATIME,LOG)
VALUES('','58237',SYSDATE,lasttime,msgout);
COMMIT;
end pub_obt_trans_prc;