pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: foo2@on-spammers2.com
To: pgsql-sql@postgresql.org
Subject: New to SQL; hopefully simple question
Date: Fri, 18 Apr 2003 22:58:09 GMT
Message-ID: <1e83d3494141f5a5be1ad65b3ebd1756@news.teranews.com> (raw)

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




view thread (3+ messages)  latest in thread

Message-ID: <1e83d3494141f5a5be1ad65b3ebd1756@news.teranews.com>
Permalink:  ../1e83d3494141f5a5be1ad65b3ebd1756@news.teranews.com/
Also on:    postgresql.org/message-id/1e83d3494141f5a5be1ad65b3ebd1756@news.teranews.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: foo2@on-spammers2.com
  Subject: Re: New to SQL; hopefully simple question
  In-Reply-To: <1e83d3494141f5a5be1ad65b3ebd1756@news.teranews.com>
  References: <1e83d3494141f5a5be1ad65b3ebd1756@news.teranews.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox