Re: Possible to prevent transaction abort?

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Adam B <adamb(at)videx(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Possible to prevent transaction abort?
Date: 2009-05-02 03:18:42
Message-ID: 49FBBB92.1050000@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adam B wrote:
> Hello all,
>
> Is it possible to prevent Postgre from aborting the transaction upon a
> constraint violation?

Not without use of savepoints.

What I like to do is bulk-insert the suspect data into a temp table
without constraints, then INSERT INTO ... SELECT it into the target
table with appropriate WHERE constraints to prevent attempts to insert
invalid values.

Another alternative is to constrain each INSERT statement with an
appropriate WHERE clause after rephrasing it in INSERT INTO ... SELECT
form .

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-05-02 03:42:31 Re: recover corrupt DB?
Previous Message Craig Ringer 2009-05-02 02:50:09 Re: recover corrupt DB?