Re: Ignoring an SQL INSERT error - Mailing list pgsql-novice

From Josh Berkus
Subject Re: Ignoring an SQL INSERT error
Date
Msg-id 200406071303.47179.josh@agliodbs.com
Whole thread Raw
In response to Ignoring an SQL INSERT error  (Shawn Chisholm <ShawnC@sandvine.com>)
List pgsql-novice
Shawn,

> 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
out.

--
Josh Berkus
Aglio Database Solutions
San Francisco

pgsql-novice by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Shut down postgres server...
Next
From: "Scott Marlowe"
Date:
Subject: Re: Shut down postgres server...