Re: PL/PGSQL question on transactions

Поиск
Список
Период
Сортировка
От Christopher Kings-Lynne
Тема Re: PL/PGSQL question on transactions
Дата
Msg-id 20020412235806.Q91940-100000@houston.familyhealth.com.au
обсуждение исходный текст
Ответ на PL/PGSQL question on transactions  ("Dan Schwitalla" <acadrace@hotmail.com>)
Список pgsql-sql
No - a function implicity runs in a transaction anyway.

Chris

On Fri, 12 Apr 2002, Dan Schwitalla wrote:

> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Dan Schwitalla"
Дата:
Сообщение: PL/PGSQL question on transactions
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Functions in Postgres