【问题标题】:PL/SQL Perfom TRIM inside of a trigger触发器内部的 PL/SQL 执行 TRIM
【发布时间】:2015-08-06 17:57:24
【问题描述】:

我正在尝试触发,当插入数据时,它会修剪正在插入的数据。

这是我正在尝试的..

CREATE OR REPLACE TRIGGER trig_trim
BEFORE INSERT ON triggertest
FOR EACH ROW

BEGIN
  TRIM(:new.testchar);  
END;
/

我做了这样的插入

INSERT INTO triggertest (testnum, testchar) VALUES (9, ' r9 ');

我收到此错误...

04098. 00000 -  "trigger '%s.%s' is invalid and failed re-validation"
*Cause:    A trigger was attempted to be retrieved for execution and was
           found to be invalid.  This also means that compilation/authorization
           failed for the trigger.
*Action:   Options are to resolve the compilation/authorization errors,
           disable the trigger, or drop the trigger.

当我只是运行代码来创建触发器时,我得到了这个

TRIGGER TRIG_TRIM compiled
Errors: check compiler log

并在编译器日志中显示“'TRIM' 不是过程或未定义”

是我的语法错误还是我的逻辑?我不知道为什么会失败。

【问题讨论】:

    标签: plsql triggers trim


    【解决方案1】:

    您的赋值语法错误。试试这个:

    :new.testchar := TRIM(:new.testchar);
    

    【讨论】:

      【解决方案2】:

      TRIM 必须将结果返回给某物。我想你想要:

       :new.testchar := TRIM(:new.testchar); 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-08-06
        • 1970-01-01
        • 1970-01-01
        • 2020-09-14
        • 1970-01-01
        • 2018-04-01
        • 2017-09-14
        • 2021-02-25
        相关资源
        最近更新 更多