X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1D6CAD1D0AE for ; Fri, 12 Dec 2003 20:56:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 93063-08 for ; Fri, 12 Dec 2003 16:55:57 -0400 (AST) Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) by svr1.postgresql.org (Postfix) with ESMTP id 71FBDD1B460 for ; Fri, 12 Dec 2003 16:55:55 -0400 (AST) Received: by ganymede.hub.org (Postfix, from userid 1000) id B5F8737CEC; Fri, 12 Dec 2003 16:53:55 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id B2DEA37CEB for ; Fri, 12 Dec 2003 16:53:55 -0400 (AST) Date: Fri, 12 Dec 2003 16:53:55 -0400 (AST) From: "Marc G. Fournier" X-X-Sender: scrappy@ganymede.hub.org To: pgsql-sql@postgresql.org Subject: Skip dups on INSERT instead of generating an error ... Message-ID: <20031212165007.L81928@ganymede.hub.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/94 X-Sequence-Number: 16260 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? ---- Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664