I want to create a trigger that execute on update of a table.
in particular on update of a table i want to update another table via a trigger but if the trigger fails (REFERENTIAL INTEGRITY– ENTITY INTEGRITY) i do not want to execute the update anymore.
Any suggestion on how to perform this?
Is it better to use a trigger or do it anagrammatically via a stored procedure?
Thanks
The DML in the trigger is part of the same action as the triggering DML. Both have to succeed or b oth fail. If the trigger raises an unhandled exception the entire statement gets rolled back.
Here is a trigger on T23 which copies the row into T42.
A successful inserrt into T23…
But this one will fail because of a unique constraint on T42.ID. As you can see the triggering statement is rolled back too …