Re: how to overwrite tuples in a table

From: Oliver Fromme <olli(at)lurza(dot)secnetix(dot)de>
To: Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com ("Pradeepkumar, Pyatalo (IE10)")
Cc: sdavis2(at)mail(dot)nih(dot)gov (Sean Davis), Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com ("Pradeepkumar, Pyatalo (IE10)"), pgsql-novice(at)postgresql(dot)org
Subject: Re: how to overwrite tuples in a table
Date: 2004-09-10 15:47:25
Message-ID: 200409101547.i8AFlPpi010977@lurza.secnetix.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


"Pradeepkumar, Pyatalo (IE10)" wrote:
> No I am not looking for UPDATE command.For updating first i should check if
> there is a tuple with the given pointid and attributeid, if present then i
> should use the UPDATE command.....thats fine. But what I wanted was a
> situation wherein, I will blindly call the insert command and the database
> takes care of overwriting the previous values.....is that possible.

I suggest you just try the UPDATE command, and if that
fails, perform an INSERT. You have to lock the table,
in case another process is trying to do the same thing
at the same time.

(Unfortunately, you cannot use a transaction, because
the failing UPDATE would abort the transaction. However,
I believe the nested-transaction feature of PostgreSQL 8
(still in beta) would allow to do such things. Someone
please correct me if I'm wrong ...)

Best regards
Oliver

--
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"I made up the term 'object-oriented', and I can tell you
I didn't have C++ in mind."
-- Alan Kay, OOPSLA '97

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2004-09-10 17:30:09 Re: Opinions Requested - PG API or Abstraction Layer
Previous Message Salerno, Vincent 2004-09-10 14:34:38 Alter session set current_schema