Subject RE: [firebird-support] DML in triggers
Author Rick Debay
> updating anything but the current row should be done in AFTER triggers
and not BEFORE triggers

I've gotten strange error messages (but everything works) when updating
the current row in an AFTER trigger.
The trigger causes a bunch of business logic to fire, which then updates
a FK in the current row to point to the results.

-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Svein Erling
Tysvaer
Sent: Wednesday, January 31, 2007 3:14 AM
To: Firebird-support
Subject: Re: [firebird-support] DML in triggers

Leyne, Sean wrote:
> Chris,
>
>> I had a Before Update trigger that included a statement like:
>> delete from ATable where SomeField=Somevalue embedded in a trigger on

>> ATable. This was causing the database to be corrupted. In other
>> tables, I'ved used triggers to update other tables with great
>> success. I need to re-create the delete functionality described
>> above, and I can do it at the application level, but I would prefer
>> that the function is part of the database logic (i.e.
>> application-independent).
>> Is this possible, and if so, how can I implement it?
>
> Nothing you should do in the database should cause a corruption, so
> the details for this issue are important
>
> Please confirm the FB version/platforms you are running.
>
> Please post the code to the problematic trigger.
>
> Sean

I agree with Sean, although I'd moderate myself to say nothing except
some hardware fault or home made UDFs should cause corruption.

In general, I'd say that updating anything but the current row should be
done in AFTER triggers and not BEFORE triggers, but even if doing this
do solve your particular problem, please try to make a reproducible test
case that shows the error you experience.

HTH,
Set

Disclaimer: This message (including attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. RxStrategies, Inc. shall not be liable for the improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system. RxStrategies, Inc. does not guarantee that the integrity of this communication has been maintained nor that this communication is free from viruses, interceptions or interference.