Re: Skip dups on INSERT instead of generating an error ... - Mailing list pgsql-sql

From scott.marlowe
Subject Re: Skip dups on INSERT instead of generating an error ...
Date
Msg-id Pine.LNX.4.33.0312121401240.18790-100000@css120.ihs.com
Whole thread Raw
In response to Skip dups on INSERT instead of generating an error ...  ("Marc G. Fournier" <scrappy@postgresql.org>)
List pgsql-sql
On Fri, 12 Dec 2003, Marc G. Fournier wrote:

> 
> I need to be able to run an INSERT INTO / SELECT FROM UNION which combines
> two tables into one ... *but* ... the INTO table has a primary key on the
> first column, so if the result of the UNION generates dups, by default, of
> course, it will generate errors ... what I'd like is to have it so that it
> just skips over those records.
> 
> First thought would be to write a quite plpgsql function that would do a
> SELECT first, to see if the value already exists, and if not, then do the
> INSERT ... but am wondering if maybe there is a cleaner way that I'm not
> thinking of?

I thought unions, by definition, couldn't create dups, unless you used the 
all keyword...  OR do you just mean that you have dup pks, not the whole 
row?  



pgsql-sql by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Skip dups on INSERT instead of generating an error ...
Next
From: "scott.marlowe"
Date:
Subject: Re: Skip dups on INSERT instead of generating an error ...