触发器update问题
希望在插入数据后,将status字段的值由1改为0,能不能通过触发器实现?
多谢!!!
触发器代码如下:
create or replace
TRIGGER TCM_TRIGGER_BLOGCOMMENTCHECK
AFTER INSERT ON BLOGCOMMENTCHECK
FOR EACH ROW
BEGIN
update NEWSBLOG.blogcommentcheck set status=0 where status=1;
END;
在执行insert时报错
错误报告:
SQL 错误: ORA-04091: table NEWSBLOG.BLOGCOMMENTCHECK is mutating, trigger/function may not see it
ORA-06512: at "NEWSBLOG.TCM_TRIGGER_BLOGCOMMENTCHECK", line 2
ORA-04088: error during execution of trigger 'NEWSBLOG.TCM_TRIGGER_BLOGCOMMENTCHECK'
04091. 00000 - "table %s.%s is mutating, trigger/function may not see it"
*Cause: A trigger (or a user defined plsql function that is referenced in
this statement) attempted to look at (or modify) a table that was
in the middle of being modified by the statement which fired it.
*Action: Rewrite the trigger (or function) so it does not read that table.