PL/SQL Perfom TRIM内部的触发器

Cra*_*aig 1 triggers plsql trim

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

这是我正在尝试..

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

BEGIN
  TRIM(:new.testchar);  
END;
/
Run Code Online (Sandbox Code Playgroud)

我像这样插入

INSERT INTO triggertest (testnum, testchar) VALUES (9, ' r9 ');
Run Code Online (Sandbox Code Playgroud)

我收到这个错误......

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.
Run Code Online (Sandbox Code Playgroud)

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

TRIGGER TRIG_TRIM compiled
Errors: check compiler log
Run Code Online (Sandbox Code Playgroud)

并在编译器日志中说"'TRIM'不是程序或未定义"

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

Gar*_*y_W 5

你的赋值语法错了.试试这个:

:new.testchar := TRIM(:new.testchar);
Run Code Online (Sandbox Code Playgroud)