Re: insert continue on error - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: insert continue on error
Date
Msg-id 471530CC.40108@iol.ie
Whole thread Raw
In response to insert continue on error  (Tom Hart <tomhart@coopfed.org>)
List pgsql-general
On 16/10/2007 20:37, Tom Hart wrote:

> What I'd like to know is if there's a way to have postgresql still
> insert the other rows, and either bounce the bad row to another table,
> or log the error in another table/file. I'm sure there's a way to do
> this, but I'm still pretty new to postgresql.

If you do the insertions within a pl/pgsql function, you can use an
EXCEPTION block to handle the error whatever way you like - have a look
here:

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

There are a couple of useful examples.

HTH,

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------

pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: Preserving view source code
Next
From: "Scott Marlowe"
Date:
Subject: Re: need help with rebuilding postgresql