Subject ODP: [firebird-support] Before Insert or After Insert trigger?
Author Karol Bieniaszewski

Hi,

 

>> Now I need to set a fields in the same table like this to track the

>>updates performed:

 

If you need to update same table then „before” update trigger is the best choice.

If you use after and run there UPDATE command you must take into accout recursive call.

Your update command run then triggers once again and if your check condition do not stop another UPDATE command

you got endless recursion, stopped in some point by engine with an error

 

>>Updating another table from a Before trigger is made in a transaction

>>that rolling back if exception occurs?

 

If you do not run it in different transaction context - like IN AUTONOMOUS TRANSACTION - then yes

 

 

regards,

Karol Bieniaszewski

 

Od: Luigi Siciliano luigisic@... [firebird-support]
Wysłano: czwartek, 6 września 2018 08:53
Do: firebird-support@yahoogroups.com
Temat: [firebird-support] Before Insert or After Insert trigger?

 

Hallo,

 

  I have an After Insert/Update trigger for a table to update another

table like this:

 

<snip>

 

  if (NEW.AGGIORNA_CONDIZIONI = 1) then

    begin

      update

        ARTICOLI_CONDIZIONI_CLIENTI ACC

      SET

 

      <snip>

    end

  else if ...

 

<snip>

 

Now I need to set a fields in the same table like this to track the

updates performed:

 

CONDIZIONI_AGGIORNATE = NEW.AGGIORNA_CONDIZIONI,

 

AGGIORNA_CONDIZIONI = 0 /* no conditions to update */

 

 

To do this I must change from After Insert/Update trigger in Before

Insert/Update trigger.

 

Is this safe or I must do other behaviour?

 

Updating another table from a Before trigger is made in a transaction

that rolling back if exception occurs?

 

Thanks.

 

--

 

Luigi Siciliano

--------------------------

 

 

 

------------------------------------

 

------------------------------------

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

Visit http://www.firebirdsql.org and click the Documentation item

on the main (top) menu.  Try FAQ and other links from the left-side menu there.

 

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

------------------------------------

 

Yahoo Groups Links

 

<*> To visit your group on the web, go to:

    http://groups.yahoo.com/group/firebird-support/

 

<*> Your email settings:

    Individual Email | Traditional

 

<*> To change settings online go to:

    http://groups.yahoo.com/group/firebird-support/join

    (Yahoo! ID required)

 

<*> To change settings via email:

    firebird-support-digest@yahoogroups.com

    firebird-support-fullfeatured@yahoogroups.com

 

<*> To unsubscribe from this group, send an email to:

    firebird-support-unsubscribe@yahoogroups.com

 

<*> Your use of Yahoo Groups is subject to:

    https://info.yahoo.com/legal/us/yahoo/utos/terms/