Re: Duplicate key insert question

From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Duplicate key insert question
Date: 2003-07-02 00:58:28
Message-ID: 3F022E34.1040808@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alvaro Herrera wrote:
>
> No, only the "second" one will fail (though it's difficult which one is
> the second)

From:

http://marc.theaimsgroup.com/?l=postgresql-general&m=105656988915991&w=2

Ian Barwick wrote:

[...]

I proposed that same solution 3 years ago. Tom shoots it down:

[...]

I couldn't get the link to work so I couldn't read why Tom shot it down.
But if Tom shot down this idea down ... then it mustn't be correct.

>>If I followed all the arguments correctly according to the thread there
>>is *no* way to do what I (and you ;) want in one simple query.
>
>
> No, there's not.

You say no, but at first you say that the proposed method works. The
proposed method, if it is correct, is simple enough for me. By simple I
mean all can be done with one query.

> You should check the returned value from the insertion
> function to see if it succeeded or not.

No, what I want if to have one query that will *always* insert if there
is no record with this primary key and *always* do nothing (not fail,
not generate an error) if there is already a record with this primary
key. I don't want to check return values :)

Thanks,

Jean-Christian Imbeault

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Maksim Likharev 2003-07-02 01:05:35 Re: Duplicate key insert question
Previous Message Alvaro Herrera 2003-07-02 00:51:11 Re: Duplicate key insert question