plsql - 行级触发器问题
问题描述
有人可以让我知道我在下面的代码中犯了什么错误为什么会出现下面的编译错误?
create or replace trigger emp_trigger
before insert or update or delete on emp
for each row
begin
if inserting then
dbms_output.put_line('Before inserting Old value is '|| :old.salary ||' New value : '|| :new.salary);
elsif updating then
dbms_output.put_line('Before updating Old value is '|| :old.salary ||' New value : '|| :new.salary);
elsif deleting then
dbms_output.put_line('Before deleting Old value is '|| :old.salary ||' New value : '|| :new.salary);
end if;
end;
/
Warning: Trigger created with compilation errors.
SQL> show err;
Errors for TRIGGER EMP_TRIGGER:
LINE/COL ERROR
-------- -----------------------------------------------------------------
3/59 PLS-00049: bad bind variable 'OLD.SALARY'
3/91 PLS-00049: bad bind variable 'NEW.SALARY'
5/58 PLS-00049: bad bind variable 'OLD.SALARY'
5/90 PLS-00049: bad bind variable 'NEW.SALARY'
7/58 PLS-00049: bad bind variable 'OLD.SALARY'
7/90 PLS-00049: bad bind variable 'NEW.SALARY'
解决方案
现在工作正常
create or replace trigger emp_trigger
before insert or update or delete on emp
for each row
begin
if inserting then
dbms_output.put_line('Before inserting Old value is '|| :old.sal ||'
New value : '|| :new.sal);
elsif updating then
dbms_output.put_line('Before updating Old value is '|| :old.sal ||'
New value : '|| :new.sal);
elsif deleting then
dbms_output.put_line('Before deleting Old value is '|| :old.sal ||'
New value : '|| :new.sal);
end if;
end;
/
推荐阅读
- excel - 循环遍历不同文件中的命名范围并在 VBA Excel 中创建 jpg
- ios - 使用 UIPickerView 选定行使用数组数据更新 UIButton 标题
- java - Java如何像Linux的命令“du”一样获取文件的磁盘空间?
- rest-assured - 无法在 RestAssured 中设置 curl 的“用户”参数
- node.js - 带有 Express JS 的路由
- python-3.x - 如何(获取或打印)我在 tkinter 上的按钮的值
- r - 重复第一行的上三角形
- javascript - 为什么 getElementsByClassName() 在使用 puppeteer 时返回 undefined?
- reactjs - package.js 中 react-native-script 和 react-native 之间的区别
- bash - bash 脚本独立运行,但不能与 cron 一起运行