on 04-22-2019 1:39 PM
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)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.