Skip site navigation (1) Skip section navigation (2)

record id of a recod which is locked for updation

From: users jtech softwares <users(dot)jtechsoftware(at)gmail(dot)com>
To: sydpug(at)postgresql(dot)org
Subject: record id of a recod which is locked for updation
Date: 2005-05-14 10:14:56
Message-ID: 10748af20505140314420b74a9@mail.gmail.com (view raw or flat)
Thread:
Lists: sydpug
hi,

I tried  web based applications using java, because all services are
run by files from the one server.

1. i have executed a query 'SELECT FOR UPDATE'.

2. select * from "pg_locks"; it will returns,

relation(oid) | database(oid) | transaction | pid |   mode  |        granted
----------+----------+-------------+------+-----------------+---------
3131286	  	3131432          1212          121    row share lock     t   


3. Then extract the pid from this table using the following query

select pid from "pg_locks" where mode='RowShareLock' and
relation(oid)=3131286 and database(oid)=3131432 ;

This will return the pid.We can inform the user the row is locked by

checking if there is any pid corresponding to
'Rowsharelock',relation(oid),and database(oid).


Here the above query will return pid corresponding to each and every
lock made on any row in this table.

It is not specific to the row that I had locked. one solution proposed
is to create a primary key corresponding to this row when this row was
locked by user1.

Then we can use this primary key to inform the details about the row
which is currently locked.

But will this work with a window based appications using swing,SWT etc
 using a centralised database.


How can i solve this problem?

thanks & regard
shameel

sydpug by date

Next:From: peter nkosiDate: 2005-05-24 15:21:54
Subject: INVESTMENT
Previous:From: users jtech softwaresDate: 2005-05-14 10:08:00
Subject: rowid of a record being locked for updation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group