How to use CLOB in a trigger
Posted: Thu 05 Nov 2015 15:17
Hello,
i have the following problem that may be relevant or not relevant on this forum.
Suppose we have a table with two CLOB columns and a trigger like:
create table clobtable (id number, clob1 clob, clob2 clob);
CREATE OR REPLACE TRIGGER B_IN_UP_CLOBTABLE
BEFORE UPDATE OR INSERT ON CLOBTABLE FOR EACH ROW
BEGIN
:NEW.CLOB2 := :NEW.CLOB1;
END;
If you run Insert and/or Update statements on this table using some tool (Toad):
INSERT INTO CLOBTABLE (id, clob1, clob2) values (1, 'aaaa','bbbb');
update clobtable set clob1 = 'cccc' where id = 1;
you will obtain expected result - both CLOB fields will contain 'aaaa' after Insert and also both fields will be 'cccc' after Update.
However, using ODAC Query Component i get a problem. Automatically generated by the Component Update statement is
UPDATE CLOBTABLE
SET
CLOB1=EMPTY_CLOB()
WHERE
ID = :Old_ID
RETURNING
CLOB1
INTO
:CLOB1
and it works fine for itself. The problem is that the trigger does not work now - the field CLOB2 is empty after this update.
How should i change the code of the trigger to obtain correct result working with a client application that uses DevArt Query Component?
Thanks,
Vladimir
i have the following problem that may be relevant or not relevant on this forum.
Suppose we have a table with two CLOB columns and a trigger like:
create table clobtable (id number, clob1 clob, clob2 clob);
CREATE OR REPLACE TRIGGER B_IN_UP_CLOBTABLE
BEFORE UPDATE OR INSERT ON CLOBTABLE FOR EACH ROW
BEGIN
:NEW.CLOB2 := :NEW.CLOB1;
END;
If you run Insert and/or Update statements on this table using some tool (Toad):
INSERT INTO CLOBTABLE (id, clob1, clob2) values (1, 'aaaa','bbbb');
update clobtable set clob1 = 'cccc' where id = 1;
you will obtain expected result - both CLOB fields will contain 'aaaa' after Insert and also both fields will be 'cccc' after Update.
However, using ODAC Query Component i get a problem. Automatically generated by the Component Update statement is
UPDATE CLOBTABLE
SET
CLOB1=EMPTY_CLOB()
WHERE
ID = :Old_ID
RETURNING
CLOB1
INTO
:CLOB1
and it works fine for itself. The problem is that the trigger does not work now - the field CLOB2 is empty after this update.
How should i change the code of the trigger to obtain correct result working with a client application that uses DevArt Query Component?
Thanks,
Vladimir