Revisited: Transactions, insert unique.

From: Lincoln Yeoh <lylyeoh(at)mecomb(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Revisited: Transactions, insert unique.
Date: 2000-04-24 06:02:17
Message-ID: 3.0.5.32.20000424140217.008f7140@pop.mecomb.po.my
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Previously I wanted to ensure that I am inserting something unique into a
table, the answer was to create a unique index on the relevant columns.

But what if I don't want to get an error which would force a rollback? Say
I want to insert something if it doesn't already exist, but update it if it
does.

Do I have to lock the whole table?

Would it be a good idea to be able to request a lock on an arbitrary string
like in MySQL? Then I could perhaps do something like

LOCK HANDLE('max255charstring',TimeoutInSeconds)
e.g.
LOCK HANDLE('mytable,field1=x,field2=y',10)

Then I could control access to a row that may not even exist, or do other
snazzy transaction stuff.

Cheerio,
Link.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Manuel Lemos 2000-04-24 06:32:30 Re: Connecting website with SQL-database.....
Previous Message Lincoln Yeoh 2000-04-24 02:37:20 Re: Connecting website with SQL-database.....