Search Postgresql Archives

Re: Avoid transaction abot if/when constraint violated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Gauthier, Dave" <dave.gauthier@xxxxxxxxx> writes:
> 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?

Either load to another table with no constraint then use it as a source
for loading the constrained one, excluding the problematic rows:

  INSERT INTO ... SELECT * FROM import.table LEFT JOIN ... ;

Or try using pgloader once the input format is CSV like rather than
INSERT.

Regards,
-- 
dim

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux