Re: Nested transaction - I am a bank ?? - Mailing list pgsql-general

From scott.marlowe
Subject Re: Nested transaction - I am a bank ??
Date
Msg-id Pine.LNX.4.33.0401131133460.22622-100000@css120.ihs.com
Whole thread Raw
In response to Re: Nested transaction - I am a bank ??  ("Joshua D. Drake" <jd@commandprompt.com>)
Responses Re: Nested transaction - I am a bank ??  (Robert Treat <xzilla@users.sourceforge.net>)
List pgsql-general
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?


pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: sql insert function
Next
From: "James Hall"
Date:
Subject: Re: Postgress and MYSQL