如何防止使用条件的触发器在表上删除和删除表
需要防止删除或更新表Transfers_details,当pointer_id == 1从传输表
注意:table transfers_details具有传输
代码的seleationship:
CREATE OR REPLACE TRIGGER Preventer_TRIGGER
BEFORE DELETE OR UPDATE ON transfers_details
FOR EACH ROW
begin
if transfers.pointer_done=1 then
raise_application_error(-20001,'Records can not be delete OR update');
end;
nese更新表Transfers_details或Delete 错误显示
Error starting at line 1 in command:
update transfers_details set fullname_sender='hani sulaiman' where id=1
Error at Command Line:1 Column:8
Error report:
SQL Error: ORA-04098: trigger 'HANI_128505.PREVENTER_TRIGGER' is invalid and failed re-validation
04098. 00000 - "trigger '%s.%s' is invalid and failed re-validation"
*Cause: A trigger was attempted to be retrieved for execution and was
found to be invalid. This also means that compilation/authorization
failed for the trigger.
*Action: Options are to resolve the compilation/authorization errors,
disable the trigger, or drop the trigger
Need prevent delete or update on table transfers_details when pointer_id ==1 from transfers table
Notice : table transfers_details has releationship with transfers
code:
CREATE OR REPLACE TRIGGER Preventer_TRIGGER
BEFORE DELETE OR UPDATE ON transfers_details
FOR EACH ROW
begin
if transfers.pointer_done=1 then
raise_application_error(-20001,'Records can not be delete OR update');
end;
whene update table transfers_details or delete
the error shows
Error starting at line 1 in command:
update transfers_details set fullname_sender='hani sulaiman' where id=1
Error at Command Line:1 Column:8
Error report:
SQL Error: ORA-04098: trigger 'HANI_128505.PREVENTER_TRIGGER' is invalid and failed re-validation
04098. 00000 - "trigger '%s.%s' is invalid and failed re-validation"
*Cause: A trigger was attempted to be retrieved for execution and was
found to be invalid. This also means that compilation/authorization
failed for the trigger.
*Action: Options are to resolve the compilation/authorization errors,
disable the trigger, or drop the trigger
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须先获取您感兴趣的值,然后验证它。
示例表:
触发器:
测试:更新无法正常工作:
删除:
但是,如果
pointer_done
不是1
再,这两个更新
和删除
工作:You'll have to fetch value you're interested in first, then verify it.
Sample tables:
Trigger:
Testing: update won't work:
Delete either:
But, if
pointer_done
isn't1
any more, bothupdate
anddelete
work: