Subject | Catching exceptions in trigger |
---|---|
Author | Gary Benade |
Post date | 2004-06-17T07:41:20Z |
I have a trigger that inserts a value into a log table for replication
purposes.
CREATE TRIGGER BUTTONS_INSERT FOR BUTTONS ACTIVE AFTER INSERT POSITION 0 AS
BEGIN
INSERT INTO CHANGE_LOG( SEQUENCE, TABLENAME, LINK, OPERATION)
VALUES ( gen_id( change_log, 1), 'BUTTONS', NEW.LINK, 'I');
END
The table it inserts into has a unique index on the LINK, TABLENAME field,
so if the record exists I get an unwanted exception error in my application.
I dont want the additional overhead in the trigger code of checking if the
record exists before inserting, so my question is:
Can I catch this exception 'c-style' inside the trigger and handle it so my
appication doesnt know about it
TIA
Gary
purposes.
CREATE TRIGGER BUTTONS_INSERT FOR BUTTONS ACTIVE AFTER INSERT POSITION 0 AS
BEGIN
INSERT INTO CHANGE_LOG( SEQUENCE, TABLENAME, LINK, OPERATION)
VALUES ( gen_id( change_log, 1), 'BUTTONS', NEW.LINK, 'I');
END
The table it inserts into has a unique index on the LINK, TABLENAME field,
so if the record exists I get an unwanted exception error in my application.
I dont want the additional overhead in the trigger code of checking if the
record exists before inserting, so my question is:
Can I catch this exception 'c-style' inside the trigger and handle it so my
appication doesnt know about it
TIA
Gary