Received: from comptechnews.com (cc993546-b.srst1.fl.home.com [24.3.77.52]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0J1kg038039 for ; Thu, 18 Jan 2001 20:46:42 -0500 (EST) (envelope-from reaster@comptechnews.com) Received: from comptechnews (reaster@localhost [127.0.0.1]) by comptechnews.com (8.10.2/8.10.2) with SMTP id f0J1pfZ09887; Thu, 18 Jan 2001 20:51:41 -0500 From: "Robert B. Easter" To: "Zolof" , pgsql-docs@postgresql.org Subject: Re: Pl/pgSQL & TRANSACTION Date: Thu, 18 Jan 2001 20:51:41 -0500 X-Mailer: KMail [version 1.1.99] Content-Type: text/plain; charset="iso-8859-1" References: <9478jp$1m25$1@news.tht.net> In-Reply-To: <9478jp$1m25$1@news.tht.net> MIME-Version: 1.0 Message-Id: <0101182051410M.02219@comptechnews> Content-Transfer-Encoding: 8bit X-Archive-Number: 200101/58 X-Sequence-Number: 193 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/ ------------