Re: how does one replace a row in Postgresql? (ala MySQL REPLACE)

From: Philip Hallstrom <philip(at)adhesivemedia(dot)com>
To: Terrence Brannon <metaperl(at)mac(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: how does one replace a row in Postgresql? (ala MySQL REPLACE)
Date: 2001-12-12 00:39:06
Message-ID: 20011211163822.O70071-100000@teak.adhesivemedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

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(at)postgresql(dot)org)
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2001-12-12 12:45:56 Re: how does one replace a row in Postgresql? (ala MySQL REPLACE)
Previous Message Terrence Brannon 2001-12-11 22:09:19 how does one replace a row in Postgresql? (ala MySQL REPLACE)

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew G. Hammond 2001-12-12 04:43:22 Re: Poolman/mySQL transaction exception on connect
Previous Message Terrence Brannon 2001-12-11 22:09:19 how does one replace a row in Postgresql? (ala MySQL REPLACE)