Re: ESQL/C: Table Open?
Posted in 1997
Rajendra, > Is it possible using ESQL/C to determine whether a table (running on > SE) is being used by another process/user? If so, how? whoops! in looking over what i just wrote below, i see above that it is SE. i assume that locking is the same on SE, but don't know for sure. everything below should still apply, but you might want to look it up to be sure. only if the user has the table locked. look at the sqlca structure. it will return a lot of information about the previous operation, as well as just the normal error return codes. the basic stategy would be to try and lock the table in exclusive mode and see what the result is. if you can lock it in exclusive mode, then no one else has any locks on the table, even shared locks. this depends on what you need this info for. you want to be careful about how you use and exclusive lock on a table, as no one else can access it while you have that lock. so you need to be sure you only have the lock on the table as long as you need it, and release it as soon as you are finished. still, that doesn't gaurantee you that no one is "using" the table. someone might be reading it with their isolation level set to dirty read, which will ignore all locks. so it kind of depends on why you need to know this, and what you mean by "using" the table. hope that helps. mickm