Trigger updating clob error

青春壹個敷衍的年華 提交于 2020-01-07 04:27:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!