问题
Trying to create a trigger that will update a clob field to rtrim
hard returns the application is tossing in.
Cannot get to the application code, so I see no other way to make potentially needed changes to the data with a trigger.
The returns are not always added.
This code is throwing error ....
Inconsistent data type expected got clob.
I thought declaring the field would avoid the issue... but no...
Any help or suggestions greatly appreciated.
CREATE OR REPLACE TRIGGER AI_master_set
AFTER INSERT ON base1
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
master_set CLOB;
BEGIN
UPDATE base1
set master_set= rtrim(master_set,chr(00))
WHERE master_set = :new.master_set;
:new.master_set:= master_set;
END;
回答1:
Based on the horse with no name, and on Oracle (11g) compound trigger not updating CLOB data field, this should simply work:
CREATE OR REPLACE TRIGGER AI_master_set
before INSERT ON base1
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
tmp_master_set CLOB;
BEGIN
tmp_master_set := rtrim(:new.master_set,chr(00));
:new.master_set:= tmp_master_set ;
END;
/
Hope it helps.
来源:https://stackoverflow.com/questions/36990785/trigger-updating-clob-error