Re: INSERT ON DUPLICATE KEY UPDATE

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: INSERT ON DUPLICATE KEY UPDATE
Date: 2004-06-19 16:20:06
Message-ID: 20040619182006.A988@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jun 18, 2004 at 08:36:21PM +0000, Eduardo Pérez Ureta wrote:
>
> On 2004-06-18 18:02:18 UTC, Richard Huxton wrote:
> > Out of curiosity, why don't you know whether you're inserting or
> > updating? It always worries me when I don't know what my application is
> > doing.
>
> This is the example:
>
> I'm downloading a list of products from the web and they already have a
> product_id (that's the primary key), in my table I have many fields that
> I use myself like comments, stock, ... But when downloading the list I
> only have the product_id, the product name, the price and the remote
> stock. So I must insert data like the remote stock without removing any
> of my data and leaving all the other columns unmodified.
This smells of that you shouldn't use the product_id as your
primary key (I know, this won't solve your problem as the
insert will still fail since most likely you'll want
product_id to be unique regardless of primary-key-ness).

Just a thought.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2004-06-19 16:57:08 Re: INSERT BEFORE Trigger
Previous Message CN 2004-06-19 16:19:27 Re: Escape chars