I have a function my_func
, the input of this function is one of the column in the same row after insertion, how to achieve this.
I have created the table using,
create table sample_trigger_hash ( INDEXID number(19,0) ,
XMLCOLUMN XMLTYPE ,
CHECKFIELD RAW(30)
) XMLTYPE COLUMN XMLCOLUMN STORE AS BINARY XML;
I am thinking of an insertion statement from DBD::Oracle in perl , with just the first two fields.
The following is my trigger,
CREATE OR REPLACE
TRIGGER hash_trigger
AFTER INSERT ON sample_trigger_hash
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
SELECT my_hash(EXTRACT(:OLD.XMLCOLUMN ,''))
INTO :NEW.CHECKFIELD
FROM dual;
END hash_trigger;
Am getting the error,
ORA-04084: cannot change NEW values for this trigger type
04084. 00000 - "cannot change NEW values for this trigger type"
*Cause: New trigger variables can only be changed in before row
insert or update triggers.
*Action: Change the trigger type or remove the variable reference.
But my requirement is to get the XMLType value after insertion, how to achieve this. If I use CLOB storage option for the XMLType, I am getting the same hash value before storing and after storing. But this is not the case when I store it as binary XML. (an XSI section is added to the binary version) More details in this other question.