Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id CE79F9FA4A5 for ; Tue, 5 Dec 2006 12:23:35 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 29971-09 for ; Tue, 5 Dec 2006 12:23:23 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by postgresql.org (Postfix) with ESMTP id 424859F9F7B for ; Tue, 5 Dec 2006 12:23:23 -0400 (AST) Received: from [194.25.154.138] (helo=webserv.wug.de) by mrelayeu.kundenserver.de (node=mrelayeu1) with ESMTP (Nemesis), id 0MKwpI-1Grd4j2XD5-0000l8; Tue, 05 Dec 2006 17:23:22 +0100 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1Grd4h-0003AO-00 for pgsql-sql@postgresql.org; Tue, 05 Dec 2006 17:23:19 +0100 Date: Tue, 5 Dec 2006 17:23:19 +0100 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: transaction in function Message-ID: <20061205162319.GB11315@a-kretschmer.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! User-Agent: Mutt/1.5.9i X-Provags-ID: kundenserver.de abuse@kundenserver.de login:51ea9561fc3f6d9539a2acd743e4748c X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/53 X-Sequence-Number: 27009 am Tue, dem 05.12.2006, um 16:25:31 +0100 mailte Marian POPESCU folgendes: > Hi, > > I want to write a function that updates several tables; if there is an > exception while updating, it should rollback the transaction and raise an > error. > > How can this be done in pgPLSQL in PostgreSQL 8.1 ? A function runs within a transaction. You can trapp errors within a function, read this: http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net