5)創建一個觸發器,使得每增加一個回帖,就在對應的主題帖總修改回復數+1
set serveroutput on;
create or replace trigger addTopic_tri after insert on T_reply
for each row
declare
v_tid number(10);
begin
select tid into v_tid from T_REPLY where tid=:new.tid;
update T_Topic
set Treply=Treply+1 where T_Topic.tid=:new.tid;
end;
insert into T_reply(Rid,Tid,Rsubject,Rcontent,Ruser,Rdate) values(reply_seq.nextval,3,'小明結婚?','我在高考',24,sysdate);
SQL 錯誤: ORA-04091: 表 USER_ZHANGZHENYUN.T_REPLY 發生了變化, 觸發器/函式不能讀它
ORA-06512: 在 "USER_ZHANGZHENYUN.ADDTOPIC_TRI", line 4
ORA-04088: 觸發器 'USER_ZHANGZHENYUN.ADDTOPIC_TRI' 執行程序中出錯
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.
TRIGGER ADDTOPIC_TRI 已編譯
uj5u.com熱心網友回復:
表 USER_ZHANGZHENYUN.T_REPLY 發生了變化, 觸發器/函式不能讀它ORA-06512: 在 "USER_ZHANGZHENYUN.ADDTOPIC_TRI", line 4
ORA-04088: 觸發器 'USER_ZHANGZHENYUN.ADDTOPIC_TRI' 執行程序中出錯
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.
大神求解???
uj5u.com熱心網友回復:
5)創建一個觸發器,使得每增加一個回帖,就在對應的主題帖總修改回復數+1set serveroutput on;
create or replace trigger addTopic_tri after insert on T_reply
for each row
declare
begin
update T_Topic
set Treply=Treply+1 where tid=:new.tid;
end;
/
show error;
uj5u.com熱心網友回復:
樓主 2 # 的陳述句,應該沒什么 問題;直接參考 :new.col_name就可以了。轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/93570.html
標籤:基礎和管理
