Maddy
Maddy

Reputation: 3816

Oracle Error ORA-04093, unable reference long data type

I am trying to create a trigger on addcomments table, which contains a long coloumn

CREATE OR REPLACE TRIGGER careventCommentssysc
AFTER INSERT 
ON addcomments
FOR EACH ROW
DECLARE
BEGIN
        cargetcomments(:NEW.addcode, :NEW.addcomment,  'INSERTING');
END careventCommentssysc;

when i try to compile this i am getting following error.

ORA-04093, references to column of type LONG are not allowed in triggers.

But i cant change the table column type to other than long.

Please help me if anyone handled this problem earlier.

Upvotes: 2

Views: 2902

Answers (1)

Gaurav Soni
Gaurav Soni

Reputation: 6338

EDIT:I think this can be done with Simple compund trigger ,as you are using ORACLE 11g,hence this will work for you.No need for any loopback dblinks.Cheers

CREATE OR REPLACE TRIGGER careventCommentssysc FOR
   INSERT
   ON t
   COMPOUND TRIGGER
   l_new_long        LONG;

   TYPE addcomment_nt
   IS
      TABLE OF addcomments%ROWTYPE
         INDEX BY SIMPLE_INTEGER;

   v_addcomment_nt   user_id_nt;
   idx               SIMPLE_INTEGER := 0;
   -- AFTER EACH ROW Section:

   AFTER EACH ROW
   IS
   BEGIN
      idx := idx + 1;
      v_addcomment_nt (idx).addcode := :NEW.addcode;
   END
   AFTER EACH ROW;

   -- AFTER STATEMENT Section:

   AFTER STATEMENT
   IS
   BEGIN
      FOR i IN v_addcomment_nt.FIRST .. v_addcomment_nt.LAST
      LOOP
         EXECUTE IMMEDIATE 'select addcomment 
                            from addcomments 
                            where addcode = :1'
            INTO   l_new_long
            USING v_addcomment_nt (i).addcode;


         cargetcomments (v_addcomment_nt (i).addcode,
                         :l_new_long,
                         'INSERTING');
      END LOOP;
   END
   AFTER STATEMENT;

END careventCommentssysc;

Upvotes: 1

Related Questions