发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
CREATE OR REPLACE TRIGGER "KPIPLANUPDATE"
BEFORE
UPDATE OF "ISDEL"
ON "TB_KPIPLAN"
REFERENCING OLD AS sOlder
NEW AS sNew FOR EACH ROW
declare
PRAGMA AUTONOMOUS_TRANSACTION; --没有这句的话,不能同时更新一个表了
type temp_cur is ref cursor;
cur_trail temp_cur;
ParentID varchar(20);
v_sql varchar(4000);
begin
v_sql := 'select KpiPlanID from tb_kpiplan A Where A.ParentID = ' ||
:sNew.kpiPlanID;
--打开游标
if not cur_trail%isopen then
open cur_trail for v_sql;
end if;
--循环更新数据
loop
fetch cur_trail
into ParentID;
exit when(cur_trail%notfound);
v_sql := 'update Tb_Kpiplan Set IsDel = ''Y'' Where KpiPlanID =' ||
ParentID;
--执行更新数据库操作
execute immediate v_sql;
commit;
end loop;
--关闭游标
if cur_trail%isopen then
close cur_trail;
end if;
end;
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。