...what is the best way to force duplicated unique
or primary key'ed row inserts not to raise errors?

duplicated rows can be ignored or updated as well
- it really doesn't matter.

to be specific, i've got:

$ psql -d mydb -c "copy mytable from 'mytable.tsv'

and, with duplicated rows there is an error:

ERROR: copy: line 1, Cannot insert a duplicate key into unique index my_unique

---

ps. i've tried:

CREATE TRIGGER my_trig
BEFORE INSERT OR UPDATE ON mytable FOR EACH
ROW EXECUTE PROCEDURE
check_primary_key('uid', 'mytable', 'uid');

but this function is missing:

ERROR: CreateTrigger: function check_primary_key() does not exist

---

...should i just code my own function?
my guess is that it will be slow
i feel there's better way...

(pgsql v7.x)

/Mirek Rusin