Oracle 复制随意表一行的SQL语句(測试Ok)

时间:2024-12-11 12:37:32

測试了非常久,网上说的方法非常多,事实上都是错误的。正确的写法:

declare
cursor rowAll is select * from tb_news where 1=1;
row1 tb_news%rowtype;
i int;
begin i := 0;
for row1 in rowAll
loop
row1.id := fn_gen_getid('tb_news');
row1.addtime := sysdate;
row1.starttime := sysdate;
row1.adduserid := -100;
insert into tb_news values row1;
commit;
end loop;
end;

误打误撞。乱写一通,没想到这样能够。只是我在查询窗体使用dbms_output.put_line(sysdate); 怎么都报错,崩溃!by default7#zbphp.com