Re: Pl/pgSQL & TRANSACTION

From: "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com>
To: "Zolof" <zolof(at)club-internet(dot)fr>, pgsql-docs(at)postgresql(dot)org
Subject: Re: Pl/pgSQL & TRANSACTION
Date: 2001-01-19 01:51:41
Message-ID: 0101182051410M.02219@comptechnews
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)comptechnews(dot)com ---------
-- CompTechNews Message Board http://www.comptechnews.com/ --
-- CompTechServ Tech Services http://www.comptechserv.com/ --
---------- http://www.comptechnews.com/~reaster/ ------------

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Orland A. Cajilig 2001-01-19 03:26:27 More Details
Previous Message Robert B. Easter 2001-01-19 01:38:26 Re: docs: syntax.sgml patch