Nested transaction - I am a bank ??

From: "Thapliyal, Deepak" <dthapliyal(at)soe(dot)sony(dot)com>
To: "'Joshua D(dot) Drake'" <jd(at)commandprompt(dot)com>, "Thapliyal, Deepak" <dthapliyal(at)soe(dot)sony(dot)com>
Cc: 'Richard Huxton' <dev(at)archonet(dot)com>, Anton(dot)Nikiforov(at)loteco(dot)ru, pgsql-general(at)postgresql(dot)org
Subject: Nested transaction - I am a bank ??
Date: 2004-01-13 18:20:31
Message-ID: 1FE5193EE2768D478949FC0AFBFFC43B06EBDE12@mail-sd1.station.sony.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Can I use a "set transaction" type mechanism within a function?

thx
Deep

-----Original Message-----
From: Joshua D. Drake [mailto:jd(at)commandprompt(dot)com]
Sent: Tuesday, January 13, 2004 10:17 AM
To: Thapliyal, Deepak
Cc: 'Richard Huxton'; Anton(dot)Nikiforov(at)loteco(dot)ru;
pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Nested transaction - I am a bank ??

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 ?
>
>Thx
>Deep
>
>-----Original Message-----
>From: pgsql-general-owner(at)postgresql(dot)org
>[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Richard Huxton
>Sent: Tuesday, January 13, 2004 4:32 AM
>To: Anton(dot)Nikiforov(at)loteco(dot)ru
>Cc: pgsql-general(at)postgresql(dot)org
>Subject: Re: [GENERAL] Parse error help needed...
>
>
>On Tuesday 13 January 2004 12:01, Anton(dot)Nikiforov(at)loteco(dot)ru wrote:
>
>
>>RH> Remove the "commit" line - functions cannot define their own
>>transactions RH> anyway.
>>Do you know if it will be solved sometime? Or this is architecture
>>dependend problem? I mean that transactions are rulez and very helpful
>>rulez when working with large databases.
>>
>>
>
>Nested transactions are on the todo list, but I don't know when they
>will
>appear.
>
>
>

--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd(at)commandprompt(dot)com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-01-13 18:24:45 Re: Best practice? Web application: single PostgreSQL
Previous Message Chris Ochs 2004-01-13 18:16:50 Pl/Perl speed