pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Philip Hallstrom <philip@adhesivemedia.com>
To: Terrence Brannon <metaperl@mac.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: how does one replace a row in Postgresql? (ala MySQL REPLACE)
Date: Tue, 11 Dec 2001 16:39:06 -0800 (PST)
Message-ID: <20011211163822.O70071-100000@teak.adhesivemedia.com> (raw)
In-Reply-To: <B9A8DB2D-EE83-11D5-9845-003065C2A10C@mac.com>

Try to UPDATE the row.  If that fails, then insert it.

There's no REPLACE in postgresql (unless someone added it and forgot to
tell me :)

On Tue, 11 Dec 2001, Terrence Brannon wrote:

> A common task is to check to see if a row with a certain primary
> key exists before inserting it. If the row exists, then you
> simply update/overwrite its contents with the new row data.
> Otherwise you insert it.
>
> MySQL has a REPLACE command which does this.
>
> I didn't see one in the Postgresql manual. How do you do this in
> Postgresql?
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>




view thread (3+ messages)  latest in thread

Message-ID: <20011211163822.O70071-100000@teak.adhesivemedia.com>
Permalink:  ../20011211163822.O70071-100000@teak.adhesivemedia.com/
Also on:    postgresql.org/message-id/20011211163822.O70071-100000@teak.adhesivemedia.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: philip@adhesivemedia.com, metaperl@mac.com
  Subject: Re: how does one replace a row in Postgresql? (ala MySQL REPLACE)
  In-Reply-To: <20011211163822.O70071-100000@teak.adhesivemedia.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