Chapter 6. Principles of SQL Remote Design
TheAdaptive Server Anywhere FIRE_TRIGGERS database option prevents
triggersfrom being fired. Ifyou set this option for the user ID used by the
MessageAgent, be careful to not use this user ID for other purposes.
Analternative approach to preventing trigger execution, available only for
AdaptiveServer Anywhere, is to use the following condition around the
bodyof your triggers:
IF CURRENT REMOTE USER IS NULL
Thismake execution conditional on whether the current user is the Message
Agent.
Triggerreplication from
AdaptiveSer ver
Anywhere
Bydefault, the Message Agent for Adaptive Server Anywhere does not
replicateactions performed by triggers; it is assumed that the trigger is
definedremotely. This avoids permissions issues and the possibility of each
actionoccurring twice. Thereare some exceptions to this rule:
Conflictresolution trigger actions Theactions carried out by conflict
resolution,or RESOLVEUPDATE,triggers
are
replicatedfrom a
consolidateddatabase to all remote databases, including the one that sent
themessage causing the conflict.
Replicationof BEFORE triggers SomeBEFORE triggers can produce
undesirableresults when using SQL Remote, and so BEFORE trigger
actionsthat modify the row being updated
are
replicated,before
UPDATEactions.
Youmust be aware of this behavior when designing your installation. For
example,a BEFORE UPDATE that bumps a counter column in the row
tokeep track of the number of times a row is updated would double count
ifreplicated, as the BEFORE UPDATE trigger will fire when the
UPDATEis replicated. To prevent this problem, you must ensure that, at
thesubscriber database, the trigger is not present or does not carry out the
replicatedaction. Also,a BEFORE UPDATE that sets a column to the
timeof the last update will get the time the UPDATE is replicated as well.
Anoption to replicate
trigger actions TheAdaptive Server Anywhere Message Agent has an option that causes it
toreplicate all trigger actions when sending messages. Thisis the
dbremote
-toption.
Ifyou use this option, you must ensure that the trigger actions are not carried
outtwice at remote databases, once by the trigger being fired at the remote
site,and once by the explicit application of the replicated actions from the
consolidateddatabase.
Toensure that trigger actions are not carried out twice, you can wrap an IF
CURRENTREMOTE USER IS NULL . . . END IF statement around the
81