Re: Nested transaction - I am a bank ??

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, "Thapliyal, Deepak" <dthapliyal(at)soe(dot)sony(dot)com>, "'Richard Huxton'" <dev(at)archonet(dot)com>, Anton(dot)Nikiforov(at)loteco(dot)ru, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Nested transaction - I am a bank ??
Date: 2004-01-13 21:41:11
Message-ID: 1074030071.29165.289.camel@camel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2004-01-13 at 13:34, scott.marlowe wrote:
> On Tue, 13 Jan 2004, Joshua D. Drake wrote:
>
> > Thapliyal, Deepak wrote:
> >
> > >Hi,
> > >
> > >Assume I have a bank app.. When customer withdraws $10 from his accouint I
> > >have to do following
> > > --> update account_summary table [subtract $10 from his account]
> > > --> update account detail_table [with other transaction details]
> > >
> > >Requirement:
> > > either both transactions should succeed or both transactions should
> > >be rolled back in case of failure.
> > >
> > >Question:
> > > if my first update succeeds and second fails (say due to space
> > >errors .. I have inconsistancy ..
> > >
> > >
> >
> > Not if you run the queries as a single transaction.
> >
> >
> > >Per the thread below stored procedures/functions cannot have commits. I
> > >assume that means that they will be implicitly commited ??
> > >
> > >How do I approach this simple requirment using psql ?
>
> Joshua, aren't functions run within their own transactions if they don't
> inherit one? Wouldn't that take care of this part as well?
>

sort of... in order to call a function you have to do "select foo()"
which creates an implicit transaction block based on the select
statement that commits when the "select statement" finishes and
everything within foo will be treated as a single transaction.

Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2004-01-13 21:46:52 Re: Nested transaction - I am a bank ??
Previous Message Jeff Bowden 2004-01-13 21:38:02 serverless postgresql