Consultor Eletrônico



Kbase P128244: FOR EACH only evaluates the ERROR flag of the buffer once when trying to check error status of BEFOR
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/01/2008
Status: Unverified

FACT(s) (Environment):

OpenEdge 10.1x
All Supported Operating Systems

SYMPTOM(s):

Attempting to check error-status of buffers in temp-table's BEFORE-TABLE

ERROR flag of the buffer is only evaluated once, resulting in either all results being returned or none

Using following code to make check:

FOR EACH ttCustomerBefore WHERE BUFFER ttCustomerBefore:ERROR = TRUE:

CAUSE:

The value of BUFFER ttCustomerBefore:ERROR is evaluated like a user-defined function and therefore it is only evaluated once before the query is executed. The buffer that is currently in memory is evaluated and this value is applied to the query and used for every record.

FIX:

Use the following construct instead:

FOR EACH ttCustomerBefore:
FIND ttCustomer WHERE ROWID(ttCustomer) = BUFFER ttCustomerBefore:AFTER-ROWID.

IF BUFFER ttCustomerBefore:ERROR = TRUE THEN DO:
/* Do Stuff */
END.
END.

Performance will not be affected since temp-tables are always local, so the WHERE condition and the IF condition are more or less equivalent.