Re: ROLLBACK in a function? - Mailing list pgsql-general

From Rory Campbell-Lange
Subject Re: ROLLBACK in a function?
Date
Msg-id 20030529085855.GA8431@campbell-lange.net
Whole thread Raw
In response to Re: ROLLBACK in a function?  (Doug McNaught <doug@mcnaught.org>)
Responses Re: ROLLBACK in a function?  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
List pgsql-general
On 28/05/03, Doug McNaught (doug@mcnaught.org) wrote:
> Rory Campbell-Lange <rory@campbell-lange.net> writes:
>
> > I understand that functions provide an implied transaction in
> > PostgreSQL.
>
> Not quite.  Every SQL statement is executed in its own transaction if
> BEGIN/END are not explicitly used.  A statment may cause zero, one or
> many function calls, but they will all execute in that transaction.
>
> > Does that mean one can ROLLBACK/COMMIT within the body of a
> > function?
>
> Not in current versions.

So in my (eg php) code I should do something like this psuedo code?

BEGIN WORK
    select function ([params])
    if
        result == 0
    then
        rollback
    else
        commit
    end if
END WORK

Rory
--
Rory Campbell-Lange
<rory@campbell-lange.net>
<www.campbell-lange.net>

pgsql-general by date:

Previous
From: Darko Prenosil
Date:
Subject: Re: Can anybody recommend an IDE for writing SQL/PLPSQL
Next
From: Karsten Hilbert
Date:
Subject: Re: ROLLBACK in a function?