Subject Re: [firebird-support] How To raise system exception, or set gds/sql code to custom value
Author Ivan Prenosil
> If there is table with PK, so if we are trying to enter dublicate
> value, we get exception. GDSCODE unique_key_violation
>
> And application receives gdscode 335544665 (or sql code -803).
>
> I need to fire same exception manually in custom trigger, that application faced same behavior as inserting dublicate
> into PK.
> Something like: App does custom job:SP,several inserts, whatever : receives exeption unique_key_violation, but in DB
> that exception is generated by custom trigger,not by PK contraint.

Just invoke the "real" exception. I.e. add this to your metadata

CREATE TABLE T(F INTEGER UNIQUE);
INSERT INTO T(F) VALUES(0);

and whenever you want to raise the exception do

INSERT INTO T(F) VALUES(0);

Ivan