Re: INSERT Trigger to check for existing records

From: Michael Lewis <mlewis(at)entrata(dot)com>
To: hagen(at)datasundae(dot)com
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: INSERT Trigger to check for existing records
Date: 2020-11-22 15:54:38
Message-ID: CAHOFxGo9etLxf=ZmgNKfsZ1jnNo8OWcvx24520oQpqHo86BMYw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If you can modify your insert statement, and live with an extra column in
the data, no trigger is needed as best I can figure.

Create a unique index over the existing columns, add a "created_on" field
and call insert on conflict (unique index) do nothing.

This should give the behavior you want.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hagen Finley 2020-11-22 17:53:45 Re: INSERT Trigger to check for existing records
Previous Message hagen 2020-11-21 18:49:06 RE: INSERT Trigger to check for existing records