Consultor Eletrônico



Kbase P115216: If the FIND-BY-ROWID method fails is does not clear the record buffer. If FIND-FIRST fails it does
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   13/04/2006
Status: Unverified

SYMPTOM(s):

If the FIND-BY-ROWID method fails is does not clear the record buffer. If FIND-FIRST fails it does clear the record buffer.

FIND-BY-ROWID does not clear the database buffer on failure, but FIND FIRST does.

The FIND-FIRST and FIND-BY-ROWID methods behave differently with regard to any available buffer records when the methods fail.

Invalid rowid for FIND-BY-ROWID method of BUFFER object <name>. (7341)

** FIND FIRST/LAST failed for table <table name> (565)


DEFINE VARIABLE hBufCustomer AS HANDLE NO-UNDO.
DEFINE VARIABLE rRowid AS ROWID NO-UNDO.

CREATE BUFFER hBufCustomer FOR TABLE "customer".

hBufCustomer:FIND-FIRST.
rrowid = ?.
hBufCustomer:FIND-BY-ROWID(rRowid) NO-ERROR.

MESSAGE "Available? " hBufCustomer:AVAILABLE
VIEW-AS ALERT-BOX INFO BUTTONS OK.

Even though the FIND-BY-ROWID fails the AVAILABLE result is YES.

DEFINE VARIABLE hBufCustomer AS HANDLE NO-UNDO.
CREATE BUFFER hBufCustomer FOR TABLE "customer".

hBufCustomer:FIND-FIRST.
hBufCustomer:FIND-FIRST ("where custnum = ?", NO-LOCK) NO-ERROR.

MESSAGE "Available? " hBufCustomer:AVAILABLE
VIEW-AS ALERT-BOX INFO BUTTONS OK.

Here the second FIND-FIRST fails and the AVAILABLE result is NO.

CAUSE:


CREATE BUFFER hBufCustomer FOR TABLE "customer".
hBufCustomer:FIND-FIRST.
rrowid = ?.
hBufCustomer:FIND-BY-ROWID(rRowid).

In the above code the error on the FIND-BY-ROWID statement is "Invalid rowid for FIND-BY-ROWID method ..." So Progress recognizes that the rowid is invalid and therefore does not even attempt to find the record. For this reason, whatever was in the buffer before is still there.

When the FIND-BY-ROWID is replaced by:

hBufCustomer:FIND-FIRST ("where custnum = ?", NO-LOCK).

Here the error is: "FIND FIRST/LAST failed ...". In this case Progress does not completely parse the WHERE clause to detect that it is being asked to do something strange. Progress simply tries to perform the FIND. But when this is done the first thing that happens is that the current record is released from the buffer. Then when the FIND fails, the buffer is empty.

FIX:

This is expected behavior. When the FIND-BY-ROWID(?) fails and the AVAILABLE function returns YES, this is in fact a bug in the application code, and should be tested for before executing the FIND-BY-ROWID method.