由于PLS-00049,触发器创建时出现编译错误:绑定变量错误

时间:2018-12-04 09:50:21

标签: plsql

我写了下面的代码来测试对emp表的审核。 但是不知道为什么会出现错误PLS-00049:绑定变量错误

create table audit_emp_values (Username varchar2(30), Time timestamp, old_salary number, new_salary number);

CREATE OR REPLACE TRIGGER audit_emp_values
AFTER delete or update or insert on employee
FOR EACH ROW
Begin
     insert into audit_employee_table values (user, sysdate, :old.old_salary, :new.new_salary);
End;
/
Warning: Trigger created with compilation errors.

SQL> show err;
Errors for TRIGGER AUDIT_EMP_VALUES:

LINE/COL ERROR
-------- -----------------------------------------------------------------
2/58     PLS-00049: bad bind variable 'OLD.OLD_SALARY'
2/75     PLS-00049: bad bind variable 'NEW.NEW_SALARY'

1 个答案:

答案 0 :(得分:0)

我能够解决该错误。下面是正确的代码。

create table audit_employee_table (Username varchar2(30), Time timestamp, old_salary number, new_salary number);

CREATE OR REPLACE TRIGGER audit_emp_values
AFTER delete or update or insert on employee
FOR EACH ROW
Begin
     insert into audit_employee_table values (user, sysdate, :OLD.salary, :NEW.salary);
End;
/