【问题标题】:unable to create a trigger using ' WHEN '无法使用“WHEN”创建触发器
【发布时间】:2016-03-20 10:14:02
【问题描述】:
create trigger info22 after insert on table_info1 for each row 
when( :new.pid < 60 )
begin
  dbms_output.put_line(' thus the given id is less than 60');
  insert into table_info2 values(:new.pid, :new.pname, :new.ploc);
end;

当我输入上述查询时,我收到一个错误

ORA-25000: invalid use of bind variable in trigger WHEN clause

【问题讨论】:

    标签: oracle plsql triggers


    【解决方案1】:

    在引用新值时不需要使用分号,因为这样做,Oracle 认为您正在尝试使用绑定变量。 尝试输入 new. 而不是 :new. 看看是否有帮助。

    【讨论】:

    • 请详细说明'new'关键字的绑定和使用
    • 当然,new 关键字用于引用输入到表中的新行。绑定变量是一个完全不同的主题,用于提高在变量中使用不同值但保持相同结构多次运行的查询的性能。欢迎您在此处阅读更多相关信息 - 例如,akadia.com/services/ora_bind_variables.html
    • 如果您发现我的回答有帮助,请将其标记为正确答案。谢谢。
    【解决方案2】:

    WHEN 子句中的new/old 引用不需要冒号

    变化:

    when( :new.pid < 60 )
    

    收件人:

    when( new.pid < 60 )
    

    【讨论】:

    • 谢谢你能详细说明什么是“绑定”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-13
    • 1970-01-01
    • 1970-01-01
    • 2013-12-12
    • 2017-08-27
    • 1970-01-01
    相关资源
    最近更新 更多