Quantcast
Channel: Why doesn't this rule prevent duplicate key violations? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Why doesn't this rule prevent duplicate key violations?

$
0
0

(postgresql) I was trying to COPY csv data into a table but I was getting duplicate key violation errors, and there's no way to tell COPY to ignore those, so following internet wisdom I tried adding this rule:

CREATE OR REPLACE RULE ignore_duplicate_inserts AS   ON INSERT TO mytable   WHERE (EXISTS ( SELECT mytable.id           FROM mytable          WHERE mytable.id = new.id)) DO NOTHING;

to circumvent the problem, but I still get those errors - any ideas why ?


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images