pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert B. Easter <reaster@comptechnews.com>
To: Zolof <zolof@club-internet.fr>
To: pgsql-docs@postgresql.org
Subject: Re: Pl/pgSQL & TRANSACTION
Date: Thu, 18 Jan 2001 20:51:41 -0500
Message-ID: <0101182051410M.02219@comptechnews> (raw)
In-Reply-To: <9478jp$1m25$1@news.tht.net>
References: <9478jp$1m25$1@news.tht.net>

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/ ------------



view thread (6+ messages)  latest in thread

Message-ID: <0101182051410M.02219@comptechnews>
Permalink:  ../0101182051410M.02219@comptechnews/
Also on:    postgresql.org/message-id/0101182051410M.02219@comptechnews

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: reaster@comptechnews.com, zolof@club-internet.fr
  Subject: Re: Pl/pgSQL & TRANSACTION
  In-Reply-To: <0101182051410M.02219@comptechnews>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox