Benjamin <benjamin@netyantra.com> writes:
> 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.
The UPDATE in your example does that already; I think you should just
drop the LOCK ...
> BEGIN; LOCK TABLE tablename in ROW EXCLUSIVE MODE; UPDATE tablename set
> colname=value WHERE rowprimary='a' ; SELECT b from tablename WHERE
> rowprimary='a'; COMMIT;
regards, tom lane