ORA-04091:表正在变异,触发器/函数可能看不到它

时间:2018-06-17 02:38:55

标签: sql oracle plsql triggers database-trigger

我的触发器命令会发生什么?

我收到了#SQL错误:ORA-04091:表正在变异,触发器/函数可能看不到它"当我更新表格中的数据时。

有人能请我吗?

错误:

One error saving changes to table "WSPADMIN"."WSP_T_REQ_MASTER":
Row 22: ORA-04091: table WSPADMIN.WSP_T_REQ_MASTER is mutating, trigger/function may not see it
ORA-06512: at "WSPADMIN.TG_AFTER_UPDATE_MASTER", line 4
ORA-04088: error during execution of trigger 'WSPADMIN.TG_AFTER_UPDATE_MASTER'

触发器:

create or replace TRIGGER "WSPADMIN"."TG_AFTER_UPDATE_MASTER"
    AFTER UPDATE 
    OF WSP_REQ_STATUS ON "WSPADMIN"."WSP_T_REQ_MASTER"
    FOR EACH ROW
    WHEN (NEW.WSP_REQ_STATUS = 'CCC')
    DECLARE REQ_NO varchar2(20);
    BEGIN
        REQ_NO := :old.WSP_REQ_NO;
        INSERT INTO WSP_T_SALE_ORDER ( WSP_REQ_NO, BU_SAP_PAYER_CODE, DEP_CODE, DEP_NAME, WSP_ITEM_CODE, WSP_QTY, UOM, TRANS_TYPE, STATUS, REQUEST_DATE, CREATE_DATE, GENERATE_DATE) 
        select A.WSP_REQ_NO, null, C.US_DEPT, D.DEP_NAME, B.WSP_ITEM_CODE, B.WSP_ITEM_QTY, 'EA', 'I', 'W', A.WSP_REQ_CREATE_DT, SYSDATE, SYSDATE  
        from WSP_T_REQ_MASTER A 
        left join WSP_T_REQ_DETAIL B on A.WSP_REQ_NO = B.WSP_REQ_NO
        left join CT_M_USER C on A.WSP_REQ_CONTACT_ID = C.US_USER_APPCODE
        left join CT_M_DEPARTMENT D on C.US_BU = D.BU_CODE and C.US_DEPT = D.DEP_CODE
        where A.WSP_REQ_NO = REQ_NO;
    END;

0 个答案:

没有答案