|
Hi,
I could be wrong but the behavior seems normal to me (thinking data base
and transaction...)
when the transaction is successful, all change to the data base
(including ones that are run by the trigger) are committed and written to
the journal...
when the transaction cannot complete.. all changes to the data
base(including the ones triggered) are rolled back from the 'before image'
in the journal...
this is a question of DB design.... all changes to the DB should
(normally) be part of the transaction...
However, I have faced one situation where the call of the trigger program
by the rollback event could have been very useful..
(the trigger calls a webservice to update another remore data base)...
Could be worth a RFE... I will vote for it.
Paul
message: 2
date: Wed, 6 Jun 2018 10:27:19 -0600
from: Nathan Andelin <nandelin@xxxxxxxxx>
subject: Re: RPGLE Trigger programs and Commit Control
I was aware that trigger programs may be called before and after DB events
(i.e. read, write, update, delete), and that commits don't invoke trigger
programs. I hadn't explored what happens during rollbacks. But it doesn't
surprise me to hear that they don't invoke triggers because programs may
perform thousands of writes, updates, or deletes before reaching a
commitment-control boundary (where either commit of rollback might be
invoked), By that time, trigger program logic may screw up data. So I
agree
that it's safer and makes more sense if commit and rollback don't invoke
trigger programs.
Of course, you'll have to decide whether your process really needs both
trigger programs and commitment control. It sounds like commitment control
and trigger programs may not be a good fit.
On Wed, Jun 6, 2018 at 9:57 AM, Craig Richards <craig@xxxxxxxxxxxxxxxx>
wrote:
Hi All,and
I'm just trying to consider the implications of having an RPGLE trigger
program on a file which is being updated by many programs, some of which
use commit control and some of which do not.
At the moment the trigger program runs in the caller's activation group
is not using commit control itself.the
The first thing I noticed is that the trigger program gets called when
UPDATE is performed, not the COMMIT, I guess I can understand why thisif
might be in terms of database integrity but it makes life tricky because
the application decides to do ROLLBK, the trigger has already done it'sonly
stuff and in my case is initiating asynchronous processing which could
be undone by building a set of reversal transactions.that
Which brings me to my second point.
If the Application performs a ROLLBK rather than a COMMIT, I thought
the subsequent change to the database would fire the trigger programagain.
Allowing me the possibility to build a reversing transaction. My testingso
far indicates that the trigger program only gets called after theinitial
UPDATE and not as a result of the ROLLBK. This does not make sense tome.
but
I understand that I could build commit control into the trigger program
in that case the normal design would be to have it in the same commitblock
and controlled by the program doing the file update.called
I don't see how this can work well because the trigger programs gets
by the UPDATE, at which point it goes ahead and does it's processing. Ifa
rollback ensues, it's too late, the trigger program has alreadyinitiated
the asynchronous processing. Yet the trigger program cannot hold backit's
processing until the COMMIT because as far as I can see it only getsthe
invoked by the UPDATE.
Has anyone else wrestled with triggers and commitment control?
Does anyone disagree with my assertion that:
1) The trigger program gets called when the UPDATE is issued not when
COMMIT is issued.
2) The trigger program does not get called if the record is reverted to
it's original state via a ROLLBK.
thanks and regards,
Craig
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
------------------------------
Subject: Digest Footer
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
digest list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
------------------------------
End of RPG400-L Digest, Vol 17, Issue 283
*****************************************
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.