Skip site navigation (1) Skip section navigation (2)

Re: Ignoring an SQL INSERT error

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Shawn Chisholm <ShawnC(at)sandvine(dot)com>,"'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Ignoring an SQL INSERT error
Date: 2004-06-07 20:03:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice

> Does anyone know of a way to perform an insert that does not abort the
> transaction if it fails?

Unfortunately, there is no way to do this at this time.   It will become 
possible when the Nested Transactions feature is added, hopefully in 
PostgreSQL7.5 (it is being tested now, you are welcome to help test).

> I am trying to implement a rule that will allow the insertion data into a
> view (for backward compatability) by performing inserts in other tables,
> and there are situations where an insert into one of the underlying tables
> is unnecessary and causes a unique key constraint violation.  Ideally I
> would like to do an insert and ignore any errors...

The best way for you to do this on your current production system is to test 
for the failure condition in advance.

If you need further help with this, I suggest hopping to the PGSQL-SQL mailing 
list; that is where the largest # of people who do rules, triggers, etc. hang 

Josh Berkus
Aglio Database Solutions
San Francisco

In response to

pgsql-novice by date

Next:From: Josh BerkusDate: 2004-06-07 20:10:04
Subject: Re: wikipedia article
Previous:From: Josh BerkusDate: 2004-06-07 19:58:33
Subject: Re: Shut down postgres server...

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group