Syntax
LOOKUP GROUP class_name { FROM | BACK } expression [ UNTIL expression ] [ SERIAL ] [ SECURE | KEYONLY ] [ MULTI expression ] [ GS status ]
Parameters
LookUp Group can be abbreviated as LU Group.
class_name
The persistent class to read.
FROM
Reads records in ascending order.
BACK
Reads records in descending order.
expression
The primary key value of the initial record to retrieve.
UNTIL expression
Specifies the primary key value of the final record to retrieve. If this command option is not specified, the record retrieval loop iterates until there are no more records.
SERIAL
Increases efficiency by retaining pointers. Refer to Serial for more information.
SECURE
Facilitates record locking of the database in applications that do not force integrity. Refer to Secure for more information.
KEYONLY
The KeyOnly command option is not supported on applications that are deployed to Windows.
For MCP-based systems, refer to KeyOnly.
MULTI expression
The Multi command option is not supported on applications that are deployed to Windows or MCP.
GS status
Indicates if there are no records retrieved, using the specified qualifier.
Description
The LookUp Group logic command reads persistent class records into memory from the database.
Upon natural termination of the LookUp Group logic command loop, the record remaining in memory is not defined. This record differs according to the host on which the application is running.
Upon explicit termination of the LookUp Group logic command loop, such as using a Break or JumpTo logic command, the record remaining in memory is the current record.
Refer to LookUp Variants for more information on the LookUp logic command.
Restrictions
The following restrictions apply to use of the LookUp Group logic command:
The initial and final primary key values to retrieve should not be altered within the LookUp Group logic command loop.
The LookUp Group Back logic command variant reads at least one record (and locks it, if the Secure command option is specified) in order to ascertain if there are any records in the specified range. This record remains locked until end-of-transaction.
Example
This example illustrates code from a report that make use of the Lookup Group command (with the Back clause) to read records from the product table in descending order, starting from the specified Product ID. The ProductID and ProductName are moved from each retrieved record into a ProductDetail frame and printed.
Message Attention “Please enter the starting product id” Accept Start_id Lookup Group Product Back (Start_id) ProductDetail.ProductID := Product.ProductID ProductDetail.ProductName := Product.ProductName ProductDetail.Print() End If (GLB.STATUS = "*****") Message Attention "No Product records found from starting ID" End
For this example, if the input is provided as Start_id = “3”, then the output is as follows. The output displays the product details of the products in descending order, starting from the specified value which is “3”. If there had been no product whose Product ID was “3”, Lookup Group with the Back clause would have looked in reverse order for the next record to retrieve.
Product ID |
Product Name |
---|---|
3 |
Gimborn R-7 |
2 |
Chips for cats |
1 | Outfit for Dogs |