PreviousNextIndex

FIND statement

Locates a single record in a table and moves that record into a record buffer.

Data movement

Syntax

FIND [ FIRST | LAST | NEXT | PREV ] record
     [ constant ]
     [ OF table ]
     [ WHERE expression ]
     [ USE-INDEX index ]
     [ USING [ FRAME frame ] field
        [ AND [ FRAME frame ] field ] ...
     ]
     [ SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK ] 
     [ NO-WAIT ]
     [ NO-PREFETCH ]
     [ NO-ERROR ] 

You can specify the OF, WHERE, USE-INDEX, and USING options in any order.

FIND CURRENT record
     [ SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK ]
     [ NO-WAIT ]
     [ NO-ERROR ] 

FIRST
LAST
NEXT
PREV
CURRENT
record
constant
OF table
WHERE expression
USE-INDEX index
USING [ FRAME frame ] field [ AND [ FRAME frame ] field ] . . .
SHARE-LOCK
EXCLUSIVE-LOCK
NO-LOCK
NO-WAIT
NO-PREFETCH
NO-ERROR
Examples

This procedure produces a report that shows all the customers who bought a particular item, and the quantity that they bought. The procedure finds an item record, the order-lines that use that item, the order associated with each order-line, and the customer associated with each order.

r-find.p
REPEAT: 
  PROMPT-FOR Item.ItemNum. 
  FIND Item USING Item.ItemNum. 
  DISPLAY Item.ItemNum Item.ItemName. 
  REPEAT: 
    FIND NEXT OrderLine OF Item. 
    FIND Order OF OrderLine. 
    FIND Customer WHERE Customer.CustNum = Order.CustNum. 
    DISPLAY Customer.Name Order.OrderNum OrderLine.Qty (TOTAL). 
  END. 
END. 

The FIND FIRST statement in the following procedure finds the first record with a name field value that alphabetically follows the name supplied by the user. The FIND NEXT statement uses the name index to find the next record in the table, using the name index.

r-find2.p
DEFINE VARIABLE start-name NO-UNDO LIKE Customer.Name. 
REPEAT: 
  SET start-name. 
  FIND FIRST Customer WHERE Customer.Name >= start-name. 
  REPEAT: 
    DISPLAY Customer.Name. 
    FIND NEXT Customer USE-INDEX name. 
  END. 
END. 

Notes
See also

AMBIGUOUS function, AVAILABLE function, CAN-FIND function, CURRENT-CHANGED function, DEFINE BUFFER statement, ERROR-STATUS system handle, FOR statement,GET statement, LOCKED function, NEW function (record buffers), PRESELECT phrase


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex