insert fail gracefully if primary key already exists

From: Alessandro Gagliardi <alessandro(at)path(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: insert fail gracefully if primary key already exists
Date: 2012-02-10 21:28:17
Message-ID: CAAB3BB+5LXG=8h6kJje4YGMKDXxzQcPrNowMKXCont+qebaxdw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have a situation where I am gradually filling in a table from another
database as the need requires. As it currently is, whenever a record comes
up, it tries to insert it into my database. If the row is already there,
the primary key collides and the insert fails. And that's fine except that
it makes for a really cluttered log (making it hard to find errors that I
really do need to pay attention to). I'm wondering if there's a better
(i.e. cleaner, but possibly also more efficient) way to do this.

Thoughts?

Thank you in advance,
-Alessandro

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message lmanorders 2012-02-10 22:29:29 Using libpq 8.4 with PostgreSQL 9.1
Previous Message Andreas Kretschmer 2012-02-10 17:54:31 Re: Functions and query analysis - EXPLAIN