Consultor Eletrônico



Kbase P42036: How to ensure that a particular ROWID is still valid before
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   9/12/2003
Status: Unverified

GOAL:

How to ensure that a particular ROWID is still valid before repositioning a query to a specific record by using the REPOSITION TO ROWID 4GL Statement?

FIX:

The REPOSITION statement does not fetch a record. Therefore, when using the REPOSITION TO ROWID statement to reposition a query to a particular record, it might happen that the rowid of the record used to reposition a query to no longer exists in the database because it may have been deleted. In this case, the REPOSITION statement will not raise the ERROR condition and will still position the cursor for the query to the "invalid" rowid. However, since the specified record has already been removed from the database a subsequent GET NEXT statement will fetch the record placed right after the specified row instead of fetching the specified row itself. In order to avoid this situation, place an IF statement right after GET NEXT to make sure that the record used to reposition a certain query to is still a valid record in the database. e.g.:

REPOSITION qCustomer TO ROWID vrRowid.
GET NEXT qCustomer EXCLUSIVE-LOCK.
IF ROWID(customer) = vrRowid THEN
DELETE Customer.