New to SQL; hopefully simple question - Mailing list pgsql-sql

From foo2@on-spammers2.com
Subject New to SQL; hopefully simple question
Date
Msg-id 1e83d3494141f5a5be1ad65b3ebd1756@news.teranews.com
Whole thread Raw
Responses Re: New to SQL; hopefully simple question  (Rod Taylor <rbt@rbt.ca>)
List pgsql-sql
I have a situation where I want to keep a bunch of ordinals in a row
of a table maintained by the database. From this table, I want to
obtain a number, and increment it in the table. This is the general
idea, abstracted to the key parts (and it works, as far as it goes:

"select valueone from ordtable"
VALUE = PQgetvalue(res,0,0)
...compute VALUE = VALUE + 1
"update ordtable SET valueone = VALUE"

...as I said, this works. however, as far as I understand it, it's
divisible and thus subject to multi-user fugue. What I need,
conceptually, is:

lock the table so anyone else waits for the unlock (not fails, waits)
do the above
unlock the table

Can anyone point me in the right direction for this? I looked at lock,
but it seems to only apply across one DB action. Yes? No?

Thanks!

Walt



Walt
Software Engineer
Black Belt Systems
pages: http://www.blackbeltsystems.com/
email: http://www.blackbeltsystems.com/contact.html



pgsql-sql by date:

Previous
From: foo2@on-spammers2.com
Date:
Subject: Ok,, what about cache for SEQUENCE - where? how?
Next
From: Tzvetan Tzankov
Date:
Subject: Deadlock problem