Thread: Insert (ignore) with unique constraint on

Insert (ignore) with unique constraint on

From
Victor Ciurus
Date:
Hi all,

What I'am trying to do using Postgresql is to make and "INSERT into
table A (2 fields) (select * from Table B) - (2 fields + unique btree
Index)" or a "COPY table_B from FILE using...". The problem is that
everytime I get duplicates from table A into table B the insert will
stop with the typical error: 'ERROR:  duplicate key violates unique
constraint "string_idx"'

Q: Is there a way (like in MySQL's INSERT IGNORE) of going on with the
INSERT / COPY FROM ... even if a dupplicate / unique constraint
violation shows on! Somekind of a 'exception/error treating' routine
in SQL or PG-PL?

Any help will be highly appreciated.

Regards,
Victor