今天在寫一個(gè)觸發(fā)器時(shí)遇到一個(gè)死鎖問題,但不知道問題出在哪兒,這個(gè)觸發(fā)器主要是用處是在T_BS_ORDERDETAIL表做增刪改操作時(shí)給主表T_BS_ORDERINFO重新合計(jì)重量體積及數(shù)量CREATE OR REPLACE TRIGGER TRIGGER_ORDERDETAIL
AFTER DELETE OR INSERT OR UPDATE ON T_BS_ORDERDETAIL FOR EACH ROWDECLARE
PRAGMA AUTONOMOUS_TRANSACTION;BEGIN
UPDATE T_BS_ORDERINFO A SET A.N_ZL =
(SELECT SUM(B.N_ZL) FROM T_BS_ORDERDETAIL B WHERE B.I_ID_ORDER = :NEW.I_ID_ORDER),
A.N_TJ =
(SELECT SUM(B.N_TJ) FROM T_BS_ORDERDETAIL B WHERE B.I_ID_ORDER = :NEW.I_ID_ORDER),
A.I_ALLCOUNT =
(SELECT SUM(B.I_COUNT) FROM T_BS_ORDERDETAIL B WHERE B.I_ID_ORDER = :NEW.I_ID_ORDER) WHERE A.ID = :NEW.I_ID_ORDER; COMMIT;END;新增時(shí)沒報(bào)錯(cuò),但修改時(shí)就報(bào)以下錯(cuò)誤
1 回答

長(zhǎng)風(fēng)秋雁
TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超7個(gè)贊
CREATE OR REPLACE TRIGGER TRIGGER_ORDERDETAIL AFTER DELETE OR INSERT OR UPDATE ON T_BS_ORDERDETAIL FOR EACH ROWBEGIN IF INSERTING THEN UPDATE T_BS_ORDERINFO A SET A.N_ZL=A.N_ZL+:NEW.N_ZL, A.N_TJ=A.N_TJ+:NEW.N_TJ, A.I_ALLCOUNT=A.I_ALLCOUNT+:NEW.I_COUNT WHERE A.ID=:NEW.I_ID_ORDER; END IF; IF UPDATING THEN UPDATE T_BS_ORDERINFO A SET A.N_ZL=A.N_ZL-:OLD.N_ZL+:NEW.N_ZL, A.N_TJ=A.N_TJ-:OLD.N_TJ+:NEW.N_TJ, A.I_ALLCOUNT=A.I_ALLCOUNT-:OLD.I_COUNT+:NEW.I_COUNT WHERE A.ID=:NEW.I_ID_ORDER; END IF; IF DELETING THEN UPDATE T_BS_ORDERINFO A SET A.N_ZL=A.N_ZL-:OLD.N_ZL, A.N_TJ=A.N_TJ-:OLD.N_TJ, A.I_ALLCOUNT=A.I_ALLCOUNT-:OLD.I_COUNT WHERE A.ID=:OLD.I_ID_ORDER; END IF;END;
- 1 回答
- 0 關(guān)注
- 1190 瀏覽
添加回答
舉報(bào)
0/150
提交
取消