From: Chris White (cjwhite) <cjwhite@cisco.com>
To: geoff@metalogicplc.com
To: pgsql-admin@postgresql.org
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> (raw)
In-Reply-To: <006401c37dea$8656ca80$af1dc9c2@goofelvis>
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
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-admin@postgresql.org
Cc: cjwhite@cisco.com, geoff@metalogicplc.com
Subject: Re: Testing for a record before update or insert without using a function.
In-Reply-To: <000401c37e06$85630af0$5c976b80@amer.cisco.com>
References: <006401c37dea$8656ca80$af1dc9c2@goofelvis> <000401c37e06$85630af0$5c976b80@amer.cisco.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