按照条件批量处理

-- 按照时间条件
declare
-- Local variables here
v_stat VARCHAR2(100) := 'to_date(''2011-12-28'',''yyyy-mm-dd'')';
cursor mycur is
select 'DELETE FROM ' || table_name || ' where stat_time < ' || v_stat || ';' go
from user_tables;
tableinfo VARCHAR2(100);
trunTab VARCHAR2(150); 
BEGIN
FOR tableinfo IN mycur LOOP
trunTab := tableinfo.go;
-- dbms_output.put_line(trunTab);
EXECUTE IMMEDIATE trunTab;
END LOOP;
COMMIT;
end;

posted on 2012-04-17 14:56  游客远  阅读(121)  评论(0)    收藏  举报

导航