Re: how to overwrite tuples in a table - Mailing list pgsql-novice

From Oliver Fromme
Subject Re: how to overwrite tuples in a table
Date
Msg-id 200409101547.i8AFlPpi010977@lurza.secnetix.de
Whole thread Raw
In response to Re: how to overwrite tuples in a table  ("Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar.Pyatalo@honeywell.com>)
Responses Re: how to overwrite tuples in a table
List 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

pgsql-novice by date:

Previous
From: Mitch Pirtle
Date:
Subject: Re: Opinions Requested - PG API or Abstraction Layer
Next
From: Josh Berkus
Date:
Subject: Re: Opinions Requested - PG API or Abstraction Layer