Re: COMMIT within function?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: COMMIT within function?
Дата
Msg-id 20041122031003.GA43060@winnie.fuhr.org
обсуждение исходный текст
Ответ на COMMIT within function?  (Dawid Kuroczko <qnex42@gmail.com>)
Ответы Re: COMMIT within function?  (Dawid Kuroczko <qnex42@gmail.com>)
Список pgsql-general
On Sun, Nov 21, 2004 at 07:29:26PM +0100, Dawid Kuroczko wrote:

> Of course I can move all this logic outside of backend, and make
> the backend just 'do' the DELETEs, ignoring errors...  But still,
> it should be doable in the procedural languages aswell.....

In PostgreSQL 8.0, PL/pgSQL functions can trap errors without rolling
back the entire transaction:

http://developer.postgresql.org/docs/postgres/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

BEGIN
    DELETE FROM values WHERE value_id = r.value_id;
EXCEPTION
    WHEN foreign_key_violation THEN
    NULL;
END;

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Certifications in military environment
Следующее
От: "Net Virtual Mailing Lists"
Дата:
Сообщение: Unions, schemas, and design questions...