PL/SQL 在触发器内部执行 TRIM
PL/SQL Perfom TRIM inside of a trigger
我正在尝试创建一个触发器,当插入数据时,它会修剪正在插入的数据。
这是我正在尝试的..
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' 不是过程或未定义”
是我的语法错误还是我的逻辑错误?我不知道为什么会失败。
TRIM 必须 return 结果。我想你想要:
:new.testchar := TRIM(:new.testchar);
您的赋值语法错误。试试这个:
:new.testchar := TRIM(:new.testchar);
我正在尝试创建一个触发器,当插入数据时,它会修剪正在插入的数据。
这是我正在尝试的..
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' 不是过程或未定义”
是我的语法错误还是我的逻辑错误?我不知道为什么会失败。
TRIM 必须 return 结果。我想你想要:
:new.testchar := TRIM(:new.testchar);
您的赋值语法错误。试试这个:
:new.testchar := TRIM(:new.testchar);