Received: from hotmail.com (f97.pav1.hotmail.com [64.4.31.97]) by postgresql.org (Postfix) with ESMTP id CF81B474E71 for ; Fri, 12 Apr 2002 11:49:56 -0400 (EDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 12 Apr 2002 08:50:01 -0700 Received: from 207.122.170.5 by pv1fd.pav1.hotmail.msn.com with HTTP; Fri, 12 Apr 2002 15:50:01 GMT X-Originating-IP: [207.122.170.5] From: "Dan Schwitalla" To: pgsql-sql@postgresql.org Subject: PL/PGSQL question on transactions Date: Fri, 12 Apr 2002 10:50:01 -0500 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 12 Apr 2002 15:50:01.0706 (UTC) FILETIME=[B4C754A0:01C1E239] X-Archive-Number: 200204/149 X-Sequence-Number: 7414 Can you imbed BEGIN; and COMMIT; statements in the body of a pl/pgsql function? I am getting a parse error upon execution when I try it. Code: CREATE FUNCTION chitadj(integer,integer) RETURNS integer AS ' DECLARE result integer; oldamount integer; BEGIN BEGIN; SELECT INTO oldamount chits FROM avatar WHERE avatar_id = $1; IF oldamount IS NULL THEN RETURN -1; END IF; IF ((oldamount < abs($2)) AND ($2 < 0)) THEN RETURN -2; END IF; result := oldamount + $2; RETURN result; COMMIT; END; ' language 'plpgsql'; ------------------------- Dan _________________________________________________________________ Join the world’s largest e-mail service with MSN Hotmail. http://www.hotmail.com