这个触发器创建有什么问题?

时间:2016-12-06 15:50:38

标签: sql oracle plsql

CREATE TRIGGER TRIGGER_HYPDM_TDC_MONITOR_ANAG
BEFORE INSERT ON HYPDM_TDC_MONITOR_ANAG REFERENCING NEW AS NEW OLD AS OLD 
FOR EACH ROW 
WHEN (:NEW.RICHIESTA_ID IS NULL)
BEGIN

  SELECT SEQ_HYPDM_TDC_MONITOR_ANAG.NEXTVAL
    INTO :NEW.RICHIESTA_ID
    FROM dual

  :NEW.CREATION_DATE := SYSDATE;
END;

这是错误:

    16:30:02  [CREATE - 0 row(s), 0.000 secs]  [Error Code: 25000, SQL State:     99999]  ORA-25000: uso non valido della bind variable nella clausola del trigger WHEN
 16:30:02  [END - 0 row(s), 0.000 secs]  [Error Code: 900, SQL State: 42000]  ORA-00900: istruzione SQL non valida

似乎是关于" WHEN"条件....

2 个答案:

答案 0 :(得分:0)

试试这个

CREATE TRIGGER TRIGGER_HYPDM_TDC_MONITOR_ANAG BEFORE INSERT ON HYPDM_TDC_MONITOR_ANAG REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW WHEN (NEW.RICHIESTA_ID IS NULL) BEGIN SELECT SEQ_HYPDM_TDC_MONITOR_ANAG.NEXTVAL INTO NEW.RICHIESTA_ID FROM dual NEW.CREATION_DATE := SYSDATE; END;

答案 1 :(得分:0)

据我理解错误消息,它声称使用了错误的绑定变量。这可能是因为使用":new"而不是" new",因为通常:表示绑定变量。