pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Testing for a record before update or insert without using a function.
2+ messages / 2 participants
[nested] [flat]

* Testing for a record before update or insert without using a function.
@ 2003-09-18 13:41  Geoff Ellis <geoff@metalogicplc.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Geoff Ellis @ 2003-09-18 13:41 UTC (permalink / raw)
  To: pgsql-admin

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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Testing for a record before update or insert without using a function.
@ 2003-09-18 17:01  Chris White (cjwhite) <cjwhite@cisco.com>
  parent: Geoff Ellis <geoff@metalogicplc.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Chris White (cjwhite) @ 2003-09-18 17:01 UTC (permalink / raw)
  To: geoff@metalogicplc.com; 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@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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-09-18 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-18 13:41 Testing for a record before update or insert without using a function. Geoff Ellis <geoff@metalogicplc.com>
2003-09-18 17:01 ` Chris White (cjwhite) <cjwhite@cisco.com>

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