violation of PRIMARY or UNIQUE KEY constraint "UNQ1" on table "Table1"
Posted: Wed 08 Jan 2014 22:23
Hello,
I get this error when I try to insert new record although I can do the same without errors inside my admin tool.
I enter the "MN_ID" value but for "POS" I leave the trigger "Table1_BI0" to do that. The Insert is working inside my admin tool but in my app I get the above error, please advise
Thanks
I get this error when I try to insert new record although I can do the same without errors inside my admin tool.
here is the SQLviolation of PRIMARY or UNIQUE KEY constraint "UNQ1" on table "Table1"
Code: Select all
CREATE TABLE Table1 (
MN_ID INTEGER NOT NULL,
POS SMALLINT NOT NULL
);
ALTER TABLE Table1 ADD CONSTRAINT UNQ1 UNIQUE (MN_ID, POS);
/* Trigger */
CREATE OR ALTER TRIGGER Table1_BI0 FOR Table1
ACTIVE BEFORE INSERT POSITION 0
AS
begin
select max(POS)+1 from table1 where Table1.MN_id = new.mn_id into new.pos;
end
Thanks