X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B6C75D1B500 for ; Thu, 18 Sep 2003 17:01:13 +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 04506-03 for ; Thu, 18 Sep 2003 14:00:42 -0300 (ADT) Received: from sj-iport-3.cisco.com (sj-iport-3-in.cisco.com [171.71.176.72]) by svr1.postgresql.org (Postfix) with ESMTP id E0C20D1B503 for ; Thu, 18 Sep 2003 14:00:40 -0300 (ADT) Received: from cisco.com (171.68.223.138) by sj-iport-3.cisco.com with ESMTP; 18 Sep 2003 10:01:07 -0700 Received: from cjwhitew2k01 (dhcp-128-107-151-92.cisco.com [128.107.151.92]) by sj-core-4.cisco.com (8.12.6/8.12.6) with ESMTP id h8IH0UBo003066; Thu, 18 Sep 2003 10:00:33 -0700 (PDT) Reply-To: From: "Chris White (cjwhite)" To: , Subject: Re: Testing for a record before update or insert without using a function. Date: Thu, 18 Sep 2003 10:01:28 -0700 Message-ID: <000401c37e06$85630af0$5c976b80@amer.cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4024 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Importance: Normal In-Reply-To: <006401c37dea$8656ca80$af1dc9c2@goofelvis> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/312 X-Sequence-Number: 10400 Why not try doing the update and if that fails i.e. returns a value of 0 (no row updated), then do the insert. Thus if your high runner case is that the entry exists, then you are going to bypass having to test if the entry exists. -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Geoff Ellis Sent: Thursday, September 18, 2003 6:41 AM To: pgsql-admin@postgresql.org Subject: [ADMIN] Testing for a record before update or insert without using a function. Is it possible to test if a record exists in a table and then if it does do an update on that table or if it doesn't do an insert ? I've looked around the documents and it seems everything points towards a function? Is this the only way or has someone done this before..... TIA Geoff ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings