Re: COMMIT within function? - Mailing list pgsql-general

From Michael Fuhr
Subject Re: COMMIT within function?
Date
Msg-id 20041122031003.GA43060@winnie.fuhr.org
Whole thread Raw
In response to COMMIT within function?  (Dawid Kuroczko <qnex42@gmail.com>)
Responses Re: COMMIT within function?
List 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 by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Certifications in military environment
Next
From: "Net Virtual Mailing Lists"
Date:
Subject: Unions, schemas, and design questions...