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

From: "Francisco Reyes" <lists(at)stringsutils(dot)com>
To: " A B " <gentosaker(at)gmail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: I often have to do "update if exist, else insert", is my database design wrong?
Date: 2008-07-25 18:46:06
Message-ID: 28514f62d3c684f482b5c68b73cc1094@stringsutils.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2008-07-25 18:59:57 Re: I often have to do "update if exist, else insert", is my database design wrong?
Previous Message Andrew Sullivan 2008-07-25 18:20:45 Re: php + postgresql