comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Handling transactions?
Date: Tue, 28 Jul 2015 08:45:48 +0200
Date: 2015-07-28T08:45:48+02:00	[thread overview]
Message-ID: <xrh840crgak6$.og5ru41qaz0o$.dlg@40tude.net> (raw)
In-Reply-To: mp6h92$q5h$1@loke.gir.dk

On Mon, 27 Jul 2015 19:10:09 -0500, Randy Brukardt wrote:

> This is typically used in a block:
> 
>     declare
>          My_Lock : Lock; -- Gets lock.
>     begin
>          -- Do operations needing the lock.
>     end; -- The lock is freed here, no matter how this block is completed.
> 
> I suspect that you could use a similar pattern for transactions (although 
> I've never tried it).

Yes, the way I did it was similar:

   declare
      My_Transaction : Transaction (...);
   begin
      -- Do operations
      Commit (My_Transaction);
   end;

The transaction object has the flag Committed set by Commit. Upon an
exception the flag remains not set and Finalize rolls back. Without an
exception the flag is set and Finalize commits.

The problem with this approach is that you cannot propagate exceptions on
errors from Finalize when commit or rollback fails.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  parent reply	other threads:[~2015-07-28  6:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 12:21 Handling transactions? EGarrulo
2015-07-27 14:16 ` Björn Lundin
2015-07-27 14:38   ` EGarrulo
2015-07-27 14:53     ` Simon Wright
2015-07-27 16:38       ` David Botton
2015-07-27 18:15         ` EGarrulo
2015-07-28  0:10           ` Randy Brukardt
2015-07-28  5:33             ` J-P. Rosen
2015-07-28  6:45             ` Dmitry A. Kazakov [this message]
2015-07-28 20:23               ` Randy Brukardt
2015-07-28  2:41         ` Norman Worth
2015-07-29  6:51 ` Jacob Sparre Andersen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox