Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Insert Update Delete CLOB in trigger

Insert Update Delete CLOB in trigger

From: Saggi <sagar_sawant2000_at_yahoo.com>
Date: 24 May 2006 11:43:11 -0700
Message-ID: <1148496191.087023.72490@38g2000cwa.googlegroups.com>


Hi,

I have trigger as given below which processes CLOB object. Bascially when record is inserted/updated/deleted in ACTIVITY table, similar record will be generated in GEAM_ACTIVITY table. Field ACTIVITY_COMMENT from ACTIVITY table which stores CLOB RTF format will be converted to plain text in variable and then stored in GEAM_ACTIVITY.ACTIVITY_COMMENT field.

Strange thing is this trigger works fine in first attempt as expected for either INSERT or UPDATE or DELETE operation. But when we perform any operation after first DML operation then it gives following error: ORA-04091: table ACTIVITY is mutating, trigger/function may not see it. Error description says table on which trigger is set is being attempted or refernced in trigger. Whereas in my trigger code I am not using ACTIVITY table anywhere.
I believe it has something to do with freeing up memory of variables which is not happening so second operation shouts giving above error.

Any thoughts????

CREATE OR REPLACE TRIGGER CONVERT_TO_PLNTXT AFTER INSERT OR UPDATE OR DELETE
ON ACTIVITY
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
DECLARE
    V_DOC CLOB;
    V_PLAIN CLOB;
    R VARCHAR2(16);
BEGIN     SELECT :NEW.STAMP2, :NEW.ACTIVITY_COMMENT     INTO R, V_DOC
    FROM DUAL;     dbms_lob.createtemporary(V_PLAIN, TRUE);     dbms_lob.append(V_PLAIN, V_DOC);
    ctx_doc.filter('RTF_ACT_COMMENT', R, V_PLAIN, plaintext => TRUE);

    IF INSERTING THEN INSERT INTO GEAM_ACTIVITY VALUES (R, V_PLAIN);
    ELSIF UPDATING THEN UPDATE GEAM_ACTIVITY SET ACTIVITY_COMMENT = V_PLAIN WHERE STAMP2 = R;
    ELSIF DELETING THEN DELETE FROM GEAM_ACTIVITY WHERE STAMP2 = R;

    END IF;     dbms_lob.freetemporary(V_PLAIN);     

END;
/ Received on Wed May 24 2006 - 13:43:11 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US