Re: I often have to do "update if exist, else insert", is my database design wrong? - Mailing list pgsql-general

From Francisco Reyes
Subject Re: I often have to do "update if exist, else insert", is my database design wrong?
Date
Msg-id 28514f62d3c684f482b5c68b73cc1094@stringsutils.com
Whole thread Raw
In response to I often have to do "update if exist, else insert", is my database design wrong?  ("A B" <gentosaker@gmail.com>)
Responses Re: I often have to do "update if exist, else insert", is my database design wrong?
List pgsql-general
> Is this normal or are there something else I could do so I don't have
> to check if it exists?

I would say that it is normal.


> For the developers: a combined  insert/update command would be nice
> :-)

Mysql has such a beast along a some other non SQL compliant extensions.

One possible approach to what you are trying to do would be:
update existing table with new values
delete from new table all records that already exist
insert remaining new records

Which can be done all in pure sql. No need to write a program.


pgsql-general by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: php + postgresql
Next
From: Steve Atkins
Date:
Subject: Re: I often have to do "update if exist, else insert", is my database design wrong?