Error-Illegal usage of identity column on trigger action

Database

Error-Illegal usage of identity column on trigger action

hi,   I have created below table and  a trigger that has triggering action on table having identity column.   create table test_trig

(s_no integer,

name varchar(30))

primary index (s_no);   create table test_trig_id

(s_no integer,

id_col INTEGER GENERATED ALWAYS  AS IDENTITY

           (START WITH 1

            INCREMENT BY 1

            MINVALUE 1

     MAXVALUE 999999999

     NO CYCLE),

name varchar(30))

primary index (s_no);  

REPLACE TRIGGER id_tbl_Ins ENABLED

   AFTER

   INSERT

    ON  grm_tmp_db.test_trig

   REFERENCING NEW  AS newrow

   FOR EACH ROW

   (

   INS grm_tmp_db.test_trig_id

  SEL newrow.s_no ,null,    newrow.name;

  )   

I'm gerring the error when I try to insert value into triggering table

  insert into  test_trig (1, 'abcd');

INSERT Failed. 5784: Illegal usage of Identity Column  

Can any one help me to resolve this error..

1 REPLY

Re: Error-Illegal usage of identity column on trigger action

Try:

REPLACE TRIGGER grm_tmp_db.id_tbl_Ins

   AFTER INSERT ON grm_tmp_db.test_trig

   REFERENCING NEW AS newrow

   FOR EACH ROW

   (

   INS grm_tmp_db.test_trig_id(s_no, id_col, name)   values(newrow.s_no ,null, newrow.name);

   )   

;

HTH.

Cheers.

Carlos.