删除表中符合条件的数据,达到1000条时候提交一次,一直到符合条件的删除为止create or replace procedure del_guest(indate in varchar2) is
begin
.....end del_guest;谢谢
begin
.....end del_guest;谢谢
解决方案 »
- oracle中的問題
- IMP-00041: 警告: 创建的对象带有编译警告,请高手指教
- 视图错误
- pl/sql中的<< warning_log_loop >> 是什么意思,没见过啊
- 。net 程序连接 oracle 10g 出现问题(8i正常)
- 这种功能怎么实现?
- 如何让oracle在每月的15号12点 执行一段存储过程? 是不是用jobs可以,如何写? 网上哪里有这方面资料?
- 能不能分析Share Pool为什么老是说不够呢
- SOS,如果500分能够救我的话,我情愿再拿出500分,让大侠喝点茶,,,,
- oracle数据库提示尝试加载Oracle客户端库时引发BadImageFormatException.如果在安装32位Oracle客户端组件的情况下64位模拟
- 第一次遇到这么怪的问题....
- 如何在 触发器 中 操作 BLOB 列 ?
i:=0;
for v in ... loop
delete ...
i:=i+1;
if i=1000 then
commit;
i:=0;
end if;
end loop;
commit;--最后一批不够1000的一起commit;
end ;
delete from 表 where g_indate >indate(参数) and rownum<1000;
commit;一直到符合条件的删除为止create or replace procedure del_guest(indate in varchar2) is
begin
end del_guest;
pragma autonomous_transaction;
begin
while 1=1 loop
EXECUTE IMMEDIATE
'delete from hn_guest where rownum <= :rn' USING 1000;
if SQL%NOTFOUND then
exit;
end if;
commit;
end loop;
end;
对吗??
end del_guest;
set timing on
declare
type typ1 IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
rec_tab typ1;
CURSOR c1 IS SELECT rowid from TABLE1 where startdate<sysdate-30 and status='S';
i number;
j number;
k number;
begin
OPEN c1;
loop
FETCH c1 BULK COLLECT INTO rec_tab LIMIT 1000;
i := c1%ROWCOUNT;
exit when not rec_tab.EXISTS(1);
forall j in rec_tab.FIRST..rec_tab.LAST
delete TABLE1 where rowid=rec_tab(j);
k := SQL%ROWCOUNT;
dbms_output.put_line('delete '||k||' rows');
commit;
exit when c1%notfound;
end loop;
close c1;
dbms_output.put_line('total: delete '||i||' rows');
end;
/
那有什么好方法啊,介绍下吗