cancel
Showing results for 
Search instead for 
Did you mean: 

unique constraint violated: Table(CLASSA)

former_member608800
Discoverer
0 Kudos

This is the syntax i used to create an update trigger



CREATE TRIGGER BOOK_UPDATE
 INSTEAD OF UPDATE ON  BOOK                                
 REFERENCING OLD ROW MYOLDROW,
 NEW ROW MYNEWROW FOR EACH ROW
 BEGIN

INSERT INTO ClASSA (rollNo,name,percentage) VALUES(:MYNEWROW.rollNo, :MYNEWROW.name, :MYNEWROW.percentage);
INSERT INTO ClassB (rollNo,english,maths) VALUES(:MYNEWROW.rollNo, :MYNEWROW.english, :MYNEWROW.maths);

END;


Trigger is getting created but when i am updating it is giving error:

This is the error i am getting :
Could not execute 'UPDATE BOOK set name='preetyzax', percentage=46, english=22, maths=14 where rollNo=24' in 169 ms 401 µs . 
[301]: unique constraint violated: "SYSTEM"."BOOK_UPDATE": line 5 col 1 (at pos 254): [301] (range 3) unique constraint violated exception: unique constraint violated: Table(CLASSA) 

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

As the message says, a unique constraint was violated when your trigger tries to insert a data record in table CLASSA. That happens, e.g. when you you try to insert a data record with the same key or if you have defined another unique constrainst on other fields and the data is not unique anymore because of that.

Answers (0)