PreviousNextIndex

PRESELECT phrase

Specifies a set of records to preselect for a DO or REPEAT block.

Syntax

PRESELECT 
  [ EACH | FIRST | LAST ] record-phrase 
  [ , [ EACH | FIRST | LAST ] record-phrase ] ... 
  [ [ BREAK ] 
       { BY expression [ DESCENDING ] 
          | COLLATE ( string , strength [ , collation ] ) [ DESCENDING ] 
       } ... 
  ] 

[ EACH | FIRST | LAST ] record-phrase
BREAK
BY expression [ DESCENDING ]
COLLATE ( string , strength [ , collation ] ) [ DESCENDING ]
string
strength
collation
Examples

To process a multi-table collection gathered by the PRESELECT option, use the last table named in the collection when you want to read the selected records. The AVM then automatically retrieves records from the other tables.

r-presl1.p
REPEAT PRESELECT EACH Order, Customer OF Order, EACH OrderLine OF Order 
  BY Order.OrderDate BY Order.CustNum BY OrderLine.ItemNum: 
  FIND NEXT OrderLine. 
  DISPLAY Order.OrderDate Order.CustNum Customer.Name OrderLine.ItemNum. 
END. 

The PRESELECT option in this example selects the logically joined record that consists of Order, OrderLine, and Customer, and makes all of these records available in the REPEAT block. Usually you perform more complex processing within the PRESELECT block.

If, within a PRESELECT block, you find a record using the ROWID of that record, the AVM disregards any other selection criteria you applied to the PRESELECT. For example, suppose the ROWID of Order number 4 is stored in the variable ord-rowid:

DO PRESELECT EACH Order NO-LOCK WHERE Order.OrderNum > 5: 
  FIND FIRST Order NO-LOCK WHERE ROWID(Order) = ord-rowid. 
  DISPLAY Order. 
END. 

In this example, the AVM finds and displays order number 4 even though the selection criteria specifies that the order number must be greater than 5. The ROWID always overrides other selection criteria. Furthermore, if you use FIND...WHERE ROWID(record) =..., the index cursor is not reset in the preselected list. That is, even if record ROWID(record) is in the preselected list, FIND NEXT does not find the record that follows it in the preselected list.

See also

DEFINE BUFFER statement, DO statement, FIND statement, REPEAT statement


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex