X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0BD53D1B52B for ; Fri, 12 Sep 2003 18:08:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 29007-04 for ; Fri, 12 Sep 2003 15:08:27 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 2C4D6D1B526 for ; Fri, 12 Sep 2003 15:08:26 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h8CI8Psn081114 for ; Fri, 12 Sep 2003 18:08:26 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h8CHta2l077070 for pgsql-sql@postgresql.org; Fri, 12 Sep 2003 17:55:36 GMT From: grk@usa.net (G. Ralph Kuntz, MD) X-Newsgroups: comp.databases.postgresql.sql Subject: Q: insert/update in same statement Date: 12 Sep 2003 10:55:17 -0700 Organization: http://groups.google.com/ Lines: 15 Message-ID: <9881c752.0309120955.72b8460e@posting.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/104 X-Sequence-Number: 15082 Is it possible to make a single SQL statement that will insert a row if it does not already exist, otherwise it will just update the fields? Actually, just a statement that will not give an error about duplicate keys would be enough for my application. Something like INSERT INTO SOME_TABLE (FIELD1, ...) VALUES (VALUE1, ...) WHERE KEY_FIELD DOES NOT EXIST; I am working in PostgreSQL 7.3.x. Thanks, Ralph