LookUp Variants

The LookUp logic command variants read records into memory from the database without the use of a profile.

The logic command variants determine how records are read into memory, and how many are read. Once a record is in memory, it can be manipulated by logic.

An End or EndExit logic statement must terminate the loop created by all variants except LookUp (singleton). The logic statements within the loop are executed for each record read.

Note: LookUp commands might be nested to 20 levels deep on Systems using Windows operating systems. On MCP-based systems, there is no limit to the levels of nesting.

Logically deleted records

In ispec methods, LookUp logic statements read logically deleted records into memory, but they are not returned and are effectively ignored. In MCP-based systems, if the last record read by a LookUp logic statement is logically deleted, that record will not be returned to the users logic within the Lookup-End block of loop, but it will be left in the ispec database buffer after the Lookup loop has been exited (outside the Lookup-End block). Therefore, the record left in the database buffer after exiting a Lookup-End block of code might be different to the last record processed within that Lookup-End block of code.

In Windows-based systems, if the last record read by a LookUp logic statement is logically deleted, it does not remain in memory. The database buffer retains the last record processed within the LookUp loop. This situation might need to be tested for as appropriate.

In report methods, LookUp logic statements read logically deleted records into memory and return them. Include logic to ensure that logically deleted records are excluded as appropriate.

Failure behavior

The failure behavior described here applies to all variants except LookUp (singleton). Refer to LookUp for more information on failure behavior of the LookUp (singleton) logic command variant.

If no records are retrieved (no record satisfies the specified criteria), the Glb.Status built-in segment attribute is set to "*****". If a record is retrieved, the Glb.Status built-in segment attribute is not set by the Determine logic command. The Glb.Status built-in segment attribute is not set when end-of-file is detected.

The Glb.Status built-in segment attribute should always be verified after a LookUp logic statement or, if a loop is created, after the End or EndExit logic statement for that loop.

Use the GS logic command option to direct the Glb.Status built-in segment attribute value to a variable. This is useful in instances where many logic statements might set the Glb.Status built-in segment attribute (for example, within nested LookUp logic statements).

The setting of Glb.Status also depends on whether records, although physically present, are marked as logically deleted. If every record retrieved by a LookUp From or LookUp Every logic statement is logically deleted, Glb.Status is set to *****.

Use of mismatching data types while reading the database is not allowed. For example, you cannot use a string in place of a numeric or vice versa while performing database read.

The rules applied for mismatching types in Lookup Variant is similar to the rules applied for Determine Variant. Refer to Determine Variants for more information.