How to find who's locking my record with rowid?

Posted by Lien on 09-Feb-2016 09:59

Hey,


The normal way to find out who's locking a record is by checking the _LOCK table with the recid.

But for partitioned tables the recid function is no longer supported.

We can do a for each over the _LOCK table but we won't be able to see with specific record is being locked because of the recid issue.

Is there an other way to see with records are locked and who's locking it?

Thanks a lot

All Replies

Posted by Fernando Souza on 09-Feb-2016 11:06

The issue with RECID on a partitioned table is that it can no longer identify a record by itself (assuming you know which table it belongs to). We advise people not to use it in their application code as you could end up finding the wrong record.

However, in the context you describe, where you know the record you are looking for and just want to find the related _Lock record, you can still call RECID and get the record's recid but you need also the partition id to find the right entry in the _Lock table. The _lock-partitionid is the field you need to look at. And you can get the partition-id of a record using the BUFFER-PARTITION-ID() function.

Posted by Lien on 10-Feb-2016 01:59

Thanks, this works if you want to find the _Lock record.

But how can you find the effective record if you check the _Lock table? So the other way around?

Because the _lock table has a recid and using the function recid with a partitioned table gives progress errors.

RECID function not supported for this table.

Posted by George Potemkin on 10-Feb-2016 05:50

How to recover records in a damaged partitioned table?

knowledgebase.progress.com/.../000047328

DEFINE VARIABLE rid AS ROWID NO-UNDO.

Rowids:TableStart("<tablename>", 1408, 3000, ?).
rid = Rowids:GetNextRowid().

DO WHILE rid <> ?:
    FIND <tablename> WHERE ROWID(<tablename>) = rid NO-ERROR.   
        IF AVAILABLE(<tablename>) THEN DO:
            EXPORT <tablename>.
        END.
    rid = Rowids:GetNextRowid().
END.

Posted by Fernando Souza on 10-Feb-2016 09:18

Yes, we do not allow you to use the RECID() function in the where clause to. The kbase mentioned in the previous post was provided for the case where you want to dump as many records as you can when you have some sort of damage to the db. The code as is relies on the current implementation of ROWIDS for OpenEdge dbs, but know that ROWID is an opaque type and we reserve the right to change its storage/format.

With that said, using the sample code posted, you should be able to find the record passing the recid found in the _Lock table record as the first and second parameters, and passing the partition id found in the _lock table as the third parameter. The GetNextRowid() method should return the rowid value for that recid/partition combination, which you can then use in the WHERE clause.

This thread is closed