Re: Replaceing records - Mailing list pgsql-general

From Harald Fuchs
Subject Re: Replaceing records
Date
Msg-id pu8yp4pohq.fsf@srv.protecting.net
Whole thread Raw
In response to Replaceing records  (Alex <alex@meerkatsoft.com>)
Responses Re: Replaceing records
List pgsql-general
In article <87ekywbqz1.fsf@stark.dyndns.tv>,
Greg Stark <gsstark@mit.edu> writes:

> Out of curiosity, what does the mysql syntax look like? How would you handle
> something where the insert and update were quite different like:

> INSERT INFO foo (pk,value,count,date_ins) values (?,?,1,now())
> OR UPDATE foo set value=?, count=count+1, date_upd=now() where pk = ?

You can't.  The only thing MySQL has to offer is

  REPLACE INTO tbl_name [(col_name,...)] VALUES (expr,...)

`REPLACE' works exactly like `INSERT', except that if an old record in
the table has the same value as a new record on a `UNIQUE' index or
`PRIMARY KEY', the old record is deleted before the new record is
inserted.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: TCL trigger doesn't work after deleting a column
Next
From: Josué Maldonado
Date:
Subject: Re: TCL trigger doesn't work after deleting a column