Board index » delphi » Another on triggers

Another on triggers


2004-06-18 04:09:38 PM
delphi87
Hi everybody,
first of all: I think triggers are a cool thing - when used carefully.
For a carefully written trigger it should be a main-issue not to
interfere with the programs using the database (different
programs/customer added triggers etc.).
Consider the following:
An "ON AFTER UPDATE" trigger triggers ;-) an update in it is code
executed on some condition only. The update statment within the trigger
should not change state variables like RowsAffected (=? RecordCount)
'cause a program could use them to see whether the original update was
successful or not (e.g. RecordCount=1 when "update tab where PK=value").
With this in mind there should be a "standard-behaviour"-trigger
template that ensures state variables (are there others?) are restored
on trigger's end - if influence not explicitly wanted.
A penny for your thoughts
Florian
BTW: I am using MS-SQL 2000 and YES I ran into problems with a trigger
similar to the one mentioned above ...
 
 

Re:Another on triggers

Florian Teichert schrieb:
Quote
Hi everybody,

An "ON AFTER UPDATE" trigger triggers ;-) an update in it is code
executed on some condition only. The update statment within the trigger
should not change state variables like RowsAffected (=? RecordCount)
'cause a program could use them to see whether the original update was
successful or not (e.g. RecordCount=1 when "update tab where PK=value").

... don't you consider this an issue? I ran in heavy trouble (including
dataloss etc.)