PL / SQL Perfom TRIM内部的触发器

时间:2015-08-06 17:57:25

标签: plsql triggers trim

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

这是我正在尝试的......

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'不是程序或未定义”

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

2 个答案:

答案 0 :(得分:5)

您的分配语法错误。试试这个:

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

答案 1 :(得分:4)

TRIM必须将结果返回到某个位置。我想你想要:

char c = (3<4)? 'y': 'n';