Consultor Eletrônico



Kbase P48900: The scope of records read with a FIND inside a FOR EACH blo
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   20/10/2003
Status: Unverified

GOAL:

How long is a record available in a FOR EACH loop block?

FIX:

When Progress reads a record from the database, it stores that record in a record buffer. The scope of the record is the portion of the procedure where that record buffer is active. Record scope determines when Progress clears the record from the buffer, when it writes the record to the database, and how long a record lock is in effect.

Generally, the scope of a record is the smallest enclosing block that encompasses all references to the record. That is, the record is available until the block ends.

On each iteration of a FOR EACH loop, Progress reads a single record from the database into the record buffer. The scope of the record is the FOR EACH block because that is the outermost block that references the record. At the end of the record scope, which is the end of the iteration that uses that record, Progress releases the record and the record is no longer available.

The following snippet demonstrates that the order record is available ONLY within the iterations that do a FIND on the order table.

FOR EACH customer:
IF CustNum MODULO 5 = 0 THEN
FIND FIRST order OF Customer NO-LOCK.
DISPLAY Customer.CustNum AVAILABLE(Customer) AVAILABLE(Order).
END.

For additional details on the Progress record scooping rules, refer to the section entitled ·Record Scoping· in the ·Progress Programming Handbook·