Re: COMMIT within function?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Dawid Kuroczko <qnex42(at)gmail(dot)com>
Cc: Pgsql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: COMMIT within function?
Date: 2004-11-22 03:10:03
Message-ID: 20041122031003.GA43060@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michelle Konzack 2004-11-22 04:20:21 Re: Certifications in military environment
Previous Message Bruce Momjian 2004-11-22 02:59:46 Re: Certifications in military environment