PLS-00049:错误的绑定变量

时间:2015-07-16 11:24:33

标签: plsql oracle-sqldeveloper

我试图写一个触发器,但我收到了这个错误:

Error(44,3): PLS-00049: bad bind variable 'NEW.NEW_REGION_CODE'
Error(45,5): PLS-00049: bad bind variable 'NEW.NEW_REGION_DESC'
Error(46,5): PLS-00049: bad bind variable 'NEW.NEW_MYHR_REGION_BI_CODE'
Error(47,3): PLS-00049: bad bind variable 'NEW.NEW_MEDBEN_NUMOF_OPTIONS'
Error(48,5): PLS-00049: bad bind variable 'NEW.NEW_DENTALBEN_NUMOF_OPTIONS'
Error(49,3): PLS-00049: bad bind variable 'NEW.NEW_NUMOFHRS_WORKD_60PRORATION'
Error(50,5): PLS-00049: bad bind variable 'NEW.NEW_NUMOFHRS_WORKD_80PRORATION'
Error(51,5): PLS-00049: bad bind variable 'NEW.NEW_CREATED_BY'
Error(52,3): PLS-00049: bad bind variable 'NEW.NEW_CREATED_ON'

这是我的触发器代码:

CREATE OR REPLACE 
TRIGGER TRG_UPDT_REGION
BEFORE UPDATE ON REGION 
FOR EACH ROW
BEGIN
    INSERT INTO REGION_HST 
( 
REGION_CODE, 
REGION_DESC, 
MYHR_REGION_BI_CODE, 
MEDBEN_NUMOF_OPTIONS, 
    DENTALBEN_NUMOF_OPTIONS, 
NUMOFHRS_WORKED_60PRORATION,
NUMOFHRS_WORKED_80PRORATION,
CREATED_BY,
CREATED_ON, 
UPDATED_BY, 
UPDATED_ON,
DELETED_BY,
DELETED_ON, 
    NEW_REGION_CODE,
NEW_REGION_DESC, 
NEW_MYHR_REGION_BI_CODE, 
NEW_MEDBEN_NUMOF_OPTIONS, 
NEW_DENTALBEN_NUMOF_OPTIONS, 
    NEW_NUMOFHRS_WORKD_60PRORATION,
NEW_NUMOFHRS_WORKD_80PRORATION, 
NEW_CREATED_BY, 
NEW_CREATED_ON, 
NEW_UPDATED_BY, 
NEW_UPDATED_ON
)
    VALUES 
    ( 
:OLD.REGION_CODE, 
:OLD.REGION_DESC, 
:OLD.MYHR_REGION_BI_CODE, 
    :OLD.MEDBEN_NUMOF_OPTIONS,
:OLD.DENTALBEN_NUMOF_OPTIONS,
:OLD.NUMOFHRS_WORKED_60PRORATION, 
    :OLD.NUMOFHRS_WORKED_80PRORATION, 
:OLD.CREATED_BY,
:OLD.CREATED_ON,
:OLD.UPDATED_BY, 
    :OLD.UPDATED_ON,
APEX_APPLICATION.G_USER,
SYSDATE, 
    :NEW.NEW_REGION_CODE,
:NEW.NEW_REGION_DESC, 
:NEW.NEW_MYHR_REGION_BI_CODE, 
    :NEW.NEW_MEDBEN_NUMOF_OPTIONS, 
:NEW.NEW_DENTALBEN_NUMOF_OPTIONS, 
    :NEW.NEW_NUMOFHRS_WORKD_60PRORATION, 
:NEW.NEW_NUMOFHRS_WORKD_80PRORATION, 
:NEW.NEW_CREATED_BY, 
    :NEW.NEW_CREATED_ON, 
APEX_APPLICATION.G_USER,
SYSDATE);
END;

我已经搜索了同样问题的问题,但没有一个问题解决了我的问题。我还检查了拼写错误,我确信拼写是正确的。

1 个答案:

答案 0 :(得分:0)

错误表示:NEW伪记录没有包含您已使用过的名称的字段,这意味着触发器所针对的表格中没有包含这些名称的列。< / p>

根据您使用的:OLD值,您刚刚在列名称中引入了虚假的NEW_前缀;所以values子句应该是:

VALUES 
( 
    :OLD.REGION_CODE, 
    ...
    :OLD.UPDATED_ON,
    APEX_APPLICATION.G_USER,
    SYSDATE, 
    :NEW.REGION_CODE,
    :NEW.REGION_DESC, 
    :NEW.MYHR_REGION_BI_CODE, 
    :NEW.MEDBEN_NUMOF_OPTIONS, 
    :NEW.DENTALBEN_NUMOF_OPTIONS, 
    :NEW.NUMOFHRS_WORKD_60PRORATION, 
    :NEW.NUMOFHRS_WORKD_80PRORATION, 
    :NEW.CREATED_BY, 
    :NEW.CREATED_ON, 
    APEX_APPLICATION.G_USER,
    SYSDATE
);