| From: | "Dan Schwitalla" <acadrace(at)hotmail(dot)com> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | PL/PGSQL question on transactions |
| Date: | 2002-04-12 15:50:01 |
| Message-ID: | F97NwGSKnt0bu5wvQaT0000c8fb@hotmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 worlds largest e-mail service with MSN Hotmail.
http://www.hotmail.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Christopher Kings-Lynne | 2002-04-12 15:58:19 | Re: PL/PGSQL question on transactions |
| Previous Message | Samuel J. Sutjiono | 2002-04-12 14:51:47 | Re: [SQL] Transactional vs. Read-only (Retrieval) database |