pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dan Schwitalla <acadrace@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: PL/PGSQL question on transactions
Date: Fri, 12 Apr 2002 10:50:01 -0500
Message-ID: <F97NwGSKnt0bu5wvQaT0000c8fb@hotmail.com> (raw)

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




view thread (3+ messages)  latest in thread

Message-ID: <F97NwGSKnt0bu5wvQaT0000c8fb@hotmail.com>
Permalink:  ../F97NwGSKnt0bu5wvQaT0000c8fb@hotmail.com/
Also on:    postgresql.org/message-id/F97NwGSKnt0bu5wvQaT0000c8fb@hotmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: acadrace@hotmail.com
  Subject: Re: PL/PGSQL question on transactions
  In-Reply-To: <F97NwGSKnt0bu5wvQaT0000c8fb@hotmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox