pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Marc G. Fournier <scrappy@postgresql.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Skip dups on INSERT instead of generating an error ...
Date: Fri, 12 Dec 2003 14:02:35 -0700 (MST)
Message-ID: <Pine.LNX.4.33.0312121401240.18790-100000@css120.ihs.com> (raw)
In-Reply-To: <20031212165007.L81928@ganymede.hub.org>

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?  




view thread (4+ messages)  latest in thread

Message-ID: <Pine.LNX.4.33.0312121401240.18790-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0312121401240.18790-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0312121401240.18790-100000@css120.ihs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: scott.marlowe@ihs.com, scrappy@postgresql.org
  Subject: Re: Skip dups on INSERT instead of generating an error ...
  In-Reply-To: <Pine.LNX.4.33.0312121401240.18790-100000@css120.ihs.com>
  References: <20031212165007.L81928@ganymede.hub.org> <Pine.LNX.4.33.0312121401240.18790-100000@css120.ihs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox