Re: most idiomatic way to "update or insert"?

From: Ron St-Pierre <rstpierre(at)syscor(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: most idiomatic way to "update or insert"?
Date: 2004-08-05 15:46:49
Message-ID: 41125669.3000402@syscor.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Huxton wrote:

>
> An "update or insert" would be useful sometimes, but it's not always
> necessary. Indeed, if I find I don't know whether I'm adding or
> updating something I take a long hard look at my design - it ususally
> means I've not thought clearly about something.

> Can you give an actual example of where you need this?

How about stocks for a simple example? Let's say you have a simple table
with the stock symbol, stock exchange, high, low, open, close and
volume. Every day you update the data for each stock. But there are
always new stocks listed on an exchange, so when a new stock shows up
you have to do an insert instead of an update.

Ron

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2004-08-05 16:38:32 Re: [GENERAL] trash talk
Previous Message Greg Stark 2004-08-05 15:07:40 Re: Sequence Question