andybeak
3/30/2015 - 2:59 PM

Ignore duplicate inserts in Postgre SQL

Ignore duplicate inserts in Postgre SQL

CREATE OR REPLACE RULE db_table_ignore_duplicate_inserts AS
    ON INSERT TO db_table
   WHERE (EXISTS ( SELECT 1
           FROM db_table
          WHERE db_table.tbl_column = NEW.tbl_column)) DO INSTEAD NOTHING;