Re: Avoid transaction abot if/when constraint violated

From: John R Pierce <pierce(at)hogranch(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Avoid transaction abot if/when constraint violated
Date: 2010-01-15 00:17:46
Message-ID: 4B4FB42A.5080207@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gauthier, Dave wrote:
>
> Hello !
>
> I have a long list of records I want to insert into a table in such a
> way as I can trap and report any/all constraint violations before
> rolling back (or opting to commit). Unfortunately, after I hit the
> first constraint violation, it aborts the transaction, and then
> reports “ERROR: current transaction is aborted, commands ignored until
> end of transaction block”.
>
> Is there a way around this?
>

use savepoints inside the transaction for each insert. your app will
have to figure out how to track the errors if it wants to postpone any
rollback/commit decision til the end.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-01-15 00:18:14 Re: Split pg_dump dump into files and then combine it back
Previous Message Dmitry Koterov 2010-01-15 00:01:19 Split pg_dump dump into files and then combine it back