pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew McMillan <andrew@catalyst.net.nz>
To: Vince Vielhaber <vev@michvhf.com>
Cc: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: PostgresSQL PHP list <pgsql-php@postgresql.org>
Cc: Manuel Lemos <mlemos@acm.org>
Subject: Re: "SQL" REPLACE SYNTAX
Date: 24 Jan 2002 00:41:44 +1300
Message-ID: <1011786105.2863.24.camel@kant.mcmillan.net.nz> (raw)
In-Reply-To: <Pine.BSF.4.40.0201230617150.21516-100000@paprika.michvhf.com>
References: <Pine.BSF.4.40.0201230617150.21516-100000@paprika.michvhf.com>

On Thu, 2002-01-24 at 00:24, Vince Vielhaber wrote:
> 
> INSERT OR REPLACE table1(a,b,c) VALUES(1,2,3) WHERE a=3 and b=4 and c=5;
> 
> On the surface it looks ok.  But..  What happens if you have a table
> that isn't just a,b,c there are actually a,b,c,d,e,f and there are more
> than one tuple with a=3 and b=4 and c=5?  Do you replace them all or
> throw an error?  Isn't this what Chris was eluding to?

OK, so the implementor would have to decide what to do if the condition
matched more than one row, but I'd be happy with _whatever_ was decided
in that regard.

To be honest, I'd even pay the six-query price that Christopher talks
about for the improved ease of maintainability of my scripts that I
would gain.  If query efficiency was a concern then I would code around
that as required, because that is usually the exception especially for
the sorts of situations where INSERT OR UPDATE syntax is useful.


> BTW, INSERT OR UPDATE seems more appropriate since you'd be doing an
> UPDATE if the row already exists.  I think that's also what Oracle uses.

You're probably right.  I do remember they use CREATE OR REPLACE for
procedures and such, but I don't use Oracle too much nowadays :-)

Cheers,
					Andrew.
-- 
--------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201    MOB: +64(21)635-694    OFFICE: +64(4)499-2267
       Are you enrolled at http://schoolreunions.co.nz/ yet?




view thread (15+ messages)  latest in thread

Message-ID: <1011786105.2863.24.camel@kant.mcmillan.net.nz>
Permalink:  ../1011786105.2863.24.camel@kant.mcmillan.net.nz/
Also on:    postgresql.org/message-id/1011786105.2863.24.camel@kant.mcmillan.net.nz

 · 

reply

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-php@postgresql.org
  Cc: andrew@catalyst.net.nz, vev@michvhf.com, chriskl@familyhealth.com.au, mlemos@acm.org
  Subject: Re: "SQL" REPLACE SYNTAX
  In-Reply-To: <1011786105.2863.24.camel@kant.mcmillan.net.nz>
  References: <Pine.BSF.4.40.0201230617150.21516-100000@paprika.michvhf.com> <1011786105.2863.24.camel@kant.mcmillan.net.nz>

* 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