Re: Pl/pgSQL & TRANSACTION - Mailing list pgsql-docs

From Robert B. Easter
Subject Re: Pl/pgSQL & TRANSACTION
Date
Msg-id 0101182051410M.02219@comptechnews
Whole thread Raw
In response to Pl/pgSQL & TRANSACTION  ("Zolof" <zolof@club-internet.fr>)
List pgsql-docs
You'll have to begin the transaction before the function is run (implicit
within a query if not in a xact).  End the transaction after the function
returns.  If the function does a RAISE EXCEPTION ''I don't like that'', then
the transaction is aborted during the function.  Again, within a query (which
triggers your function), a transaction is begun implicity if a transaction is
not begun explicity beforehand with BEGIN.


On Thursday 18 January 2001 12:16, Zolof wrote:
> This code doesn't work. I use Begin Work to start a transaction but BEGIN
> is a PL/pgSQL command so I have a parse error when executing it.
>
> CREATE FUNCTION a () RETURNS int4 AS '
> BEGIN
>    BEGIN WORK;
>    COMMIT WORK;
>     return 1;
>     END;
> ' LANGUAGE 'plpgsql';
>
> What's wrong ????

--
-------- Robert B. Easter  reaster@comptechnews.com ---------
-- CompTechNews Message Board http://www.comptechnews.com/ --
-- CompTechServ Tech Services http://www.comptechserv.com/ --
---------- http://www.comptechnews.com/~reaster/ ------------

pgsql-docs by date:

Previous
From: "Zolof"
Date:
Subject: Pl/pgSQL & TRANSACTION
Next
From: "Orland A. Cajilig"
Date:
Subject: More Details