multiple statements.. and locking

From: Benjamin <benjamin(at)netyantra(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: multiple statements.. and locking
Date: 2004-04-01 14:49:33
Message-ID: 406C2BFD.4080905@netyantra.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


Hi there,

Novice I am, when it comes to PostGreSql.
Would like to be in the know.

At this point of time, I am stuck at one peculiar problem.
I read of a similar problem in the archives, not not quite wot i was
lookin for.

I have a C application. I have to modify a row in a table, n then
immediately access a field in that row.
These operation of modifying and accessing has to be atomic.So, i have
to lock the row.

So, for that, I have prepared a query, having

BEGIN; LOCK TABLE tablename in ROW EXCLUSIVE MODE; UPDATE tablename set
colname=value WHERE rowprimary='a' ; SELECT b from tablename WHERE
rowprimary='a'; COMMIT;

n then doin a - PGexec(connection, query); PQresultStatus(pgresult);

i am not sure, if i am doin the rite thing.
i read in one of the archive mails, abt using PQsendQuery.

how do i get the results back??wot structure will have the results??
is such locking and succesive accesing fields possible??

Some help regarding this would be greatly appreciated.

Thanx.

Hope to get into the developers list.. someday ;-)

cheerz

--

Benjamin Jacob.

Disclaimer :
------------------------------------------------------------------------------
If you are not the intended recipient of this transmission to whom it is
addressed, or have received this transmission in error, you are hereby
notified that any dissemination, distribution or copying of this transmission
is strictly prohibited. Please notify us immediately and delete this e-mail
from your system. The sender does not accept liability for any errors or
omissions in the contents of this message which arise as a result of e-mail
transmission, which cannot be guaranteed to be secure or error-free as
information could be intercepted, corrupted, lost, destroyed, arrive late or
incomplete, arrive at wrong address or contain viruses. If verification
is required please request a hard-copy version. This e-mail contains only the
personal opinions of the sender and does not represent an official
communication from NetYantra of any manner.
------------------------------------------------------------------------------

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michal 2004-04-02 16:59:52 Problem with pgaccess
Previous Message joseph speigle 2004-04-01 00:20:19 Re: create user