Re: Savepoints in PL/pgSQL

Поиск
Список
Период
Сортировка
От Bernd Helmle
Тема Re: Savepoints in PL/pgSQL
Дата
Msg-id 30483a97cc63e671a4fc5c681f4cf85a@oopsware.de
обсуждение исходный текст
Ответ на Savepoints in PL/pgSQL  ("BigSmoke" <bigsmoke@gmail.com>)
Ответы Re: Savepoints in PL/pgSQL  ("BigSmoke" <bigsmoke@gmail.com>)
Список pgsql-general


On 19 Dec 2006 07:05:10 -0800, "BigSmoke" <bigsmoke@gmail.com> wrote:
> I understand that due to a lack of nested transaction support, it is
> not possible to use START TRANSACTION within a PL/PgSQL function. What
> I, however, do not understand is why I can't use SAVEPOINT either. I'm
> writing long test functions wherein, at the start of the function, I'd
> like to define all test data followed by a "SAVEPOINT
> fresh_test_data;". Will this become possible in the (near) future? I
> mean, savepoints are of limited use to me if they imply that I can't
> stick my tests in stored procedures.
>

Use

BEGIN

  ...

EXCEPTION

  ...

END;

Blocks instead. The pl/pgsql exception handling is implemented on top
of PostgreSQL's SAVEPOINT infrastructure. We are lacking user defined
exception support, but you can raise generic errors with RAISE EXCEPTION.

See

http://www.postgresql.org/docs/8.2/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

for details.

Bernd

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

Предыдущее
От: Marc Evans
Дата:
Сообщение: psql too noisy
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: psql too noisy