Re: Testing for a record before update or insert without using a function.

From: "Chris White (cjwhite)" <cjwhite(at)cisco(dot)com>
To: <geoff(at)metalogicplc(dot)com>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Testing for a record before update or insert without using a function.
Date: 2003-09-18 17:01:28
Message-ID: 000401c37e06$85630af0$5c976b80@amer.cisco.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Geoff Ellis
Sent: Thursday, September 18, 2003 6:41 AM
To: pgsql-admin(at)postgresql(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Josh Berkus 2003-09-18 17:50:34 Re: [PERFORM] How to force an Index ?
Previous Message Tom Lane 2003-09-18 16:16:10 Re: [PERFORM] How to force an Index ?