使用oracle11g触发sqldeveloper中的编译错误

时间:2015-03-11 22:54:09

标签: oracle triggers oracle11g oracle-sqldeveloper

我一直在研究触发器 [http://www.tutorialspoint.com/plsql/plsql_triggers.htm][1]  用sqldeveloper和我连接Oracle 11g数据库。我成功创建了客户表。但是当我尝试创建触发器时:

CREATE OR REPLACE TRIGGER display_salary_changes
BEFORE DELETE OR INSERT OR UPDATE ON customers
FOR EACH ROW
WHEN (NEW.ID > 0)
DECLARE
   sal_diff number;
BEGIN
   sal_diff := :NEW.salary  - :OLD.salary;
   dbms_output.put_line('Old salary: ' || :OLD.salary);
   dbms_output.put_line('New salary: ' || :NEW.salary);
   dbms_output.put_line('Salary difference: ' || sal_diff);
END; 

我收到这些错误:

Error starting at line : 1 in command -
CREATE OR REPLACE TRIGGER display_salary_changes
BEFORE DELETE OR INSERT OR UPDATE ON customers
FOR EACH ROW
WHEN (NEW.ID > 0)
  DECLARE
   sal_diff number
Error report -
SQL Command: trıgger DISPLAY_SALARY_CHANGES
Failed: Warning: yürütme uyarı ile tamamlandı

Error starting at line : 7 in command -
BEGIN
    sal_diff := :NEW.salary  - :OLD.salary;
    dbms_output.put_line('Old salary: ' || :OLD.salary);
    dbms_output.put_line('New salary: ' || :NEW.salary);
    dbms_output.put_line('Salary difference: ' || sal_diff);
END;
Error report -
ORA-06550: line 2, column 5:
PLS-00201: identifier 'SAL_DIFF' must be declared
ORA-06550: line 2, column 5:
PL/SQL: Statement ignored
ORA-06550: line 3, column 60:
PLS-00487: Invalid reference to variable 'SQLDEVBIND1Z_2'
ORA-06550: line 3, column 5:
PL/SQL: Statement ignored
ORA-06550: line 4, column 60:
PLS-00487: Invalid reference to variable 'SQLDEVBIND1Z_1'
ORA-06550: line 4, column 5:
PL/SQL: Statement ignored
ORA-06550: line 5, column 51:
PLS-00201: identifier 'SAL_DIFF' must be declared
ORA-06550: line 5, column 5:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

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

1 个答案:

答案 0 :(得分:0)

似乎是相同的"保护文字"这里描述的功能 http://krisrice.io/2015-09-11-sqlcl-more-secure-now-with-rest/