PL/PGSQL question on transactions - Mailing list pgsql-sql

From Dan Schwitalla
Subject PL/PGSQL question on transactions
Date
Msg-id F97NwGSKnt0bu5wvQaT0000c8fb@hotmail.com
Whole thread Raw
Responses Re: PL/PGSQL question on transactions  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
List pgsql-sql
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



pgsql-sql by date:

Previous
From: "Samuel J. Sutjiono"
Date:
Subject: Re: Transactional vs. Read-only (Retrieval) database
Next
From: Christopher Kings-Lynne
Date:
Subject: Re: PL/PGSQL question on transactions