X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id BE23D9DC81A for ; Tue, 14 Mar 2006 19:11:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42192-02 for ; Tue, 14 Mar 2006 19:11:29 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) by postgresql.org (Postfix) with ESMTP id 3A3D89DC80A for ; Tue, 14 Mar 2006 19:11:25 -0400 (AST) Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) by mx1.surnet.cl with ESMTP; 14 Mar 2006 19:11:20 -0400 X-IronPort-AV: i="4.02,192,1139194800"; d="scan'208"; a="46416468:sNHT22904353198" Received: from alvh.no-ip.org (201.221.200.135) by cluster.surnet.cl (7.0.043) (authenticated as alvherre@surnet.cl) id 43A978FD00A60609; Tue, 14 Mar 2006 19:11:19 -0400 Received: by alvh.no-ip.org (Postfix, from userid 1000) id 1029EC3A2CB; Tue, 14 Mar 2006 19:11:19 -0400 (CLT) Date: Tue, 14 Mar 2006 19:11:18 -0400 From: Alvaro Herrera To: Scott Petersen Cc: pgsql-sql@postgresql.org Subject: Re: Savepoint/Rollback in functions Message-ID: <20060314231118.GB8263@surnet.cl> Mail-Followup-To: Scott Petersen , pgsql-sql@postgresql.org References: <4417469C.8020600@softhome.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4417469C.8020600@softhome.net> User-Agent: Mutt/1.5.11+cvs20060126 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.597 required=5 tests=[AWL=0.597] X-Spam-Score: 0.597 X-Spam-Level: X-Archive-Number: 200603/224 X-Sequence-Number: 24570 Scott Petersen wrote: Hi, > Question 1: does pg/psql functions allow "SAVEPOINT/ROLLBACK" > functionality? (if so how?) Yes. However, you cannot use that syntax directly. You rather use it by establishing EXCEPTION clauses in BEGIN/END blocks. Upon entering any BEGIN/END block which has an EXCEPTION clause, an implicit SAVEPOINT is executed. If any exception (read: error) is found while executing the block, the savepoint will be automatically rolled back and control passed to the EXCEPTION block. HTH, -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.