FIND FIRST LAST NEXT PREV record
constant OF tableindex USING FRAME frame fieldUSE-INDEX
AND FRAME frame field SHARE-LOCK EXCLUSIVE-LOCK NO-LOCK
NO-WAIT NO-PREFETCH NO-ERROR
FIND CURRENT record
SHARE-LOCK EXCLUSIVE-LOCK NO-LOCK NO-WAIT NO-ERRORFinds the first record in the table that meets the characteristics you might have specified with record. If the buffer named in the record was preselected in a DO or REPEAT statement, FIND locates the first record in that preselected subset of records.Finds the last record in the table that meets the specified characteristics of the record. If the buffer named in the record was preselected in a DO or REPEAT statement, FIND locates the last record in that preselected subset of records.Finds the next record in the table that meets the specified characteristics of the record. If no record has been found, the buffer contents specified by record are unknown, with a ROWID equal to the Unknown value (?). If the buffer named in the record was preselected in a DO or REPEAT statement, FIND locates the next record in that preselected subset of records.Finds the previous record in the table. If no record has been found, the buffer contents specified by record are unknown, with a ROWID equal to the Unknown value (?). If the buffer named in the record was preselected in a DO or REPEAT statement, FIND locates the previous record in that preselected subset of records.Identifies the record you want to retrieve. The record parameter can be a reference to a database table or a defined buffer.
FIND Customer 1.ABL converts this FIND statement with the constant option of 1.
FIND Customer WHERE Customer.CustNum = 1.The CustNum field is the only component of the primary index of the Customer table. If you use the constant option, you must use it once in a single Record phrase, and it must precede any other options in the Record phrase.OF table
PROMPT-FOR Order.OrderNum.FIND Order USING OrderNum.DISPLAY Order.FIND Customer OF Order.DISPLAY Customer.
FIND Customer WHERE Customer.CustNum = Order.CustNum.WHERE expressionQualifies the records you want to access. The expression is a constant, field name, variable name, or expression whose value you want to use to select records. You can use the WHERE keyword even if you do not supply an expression.
FOR EACH Customer WHERE {*}The WHERE clause may not work the same way against a DataServer as it does against the OpenEdge database. Refer to the appropriate DataServer Guide (OpenEdge Data Management: DataServer for ODBC or OpenEdge Data Management: DataServer for Oracle) for additional information on how this feature will perform.USE-INDEX index
PROMPT-FOR Customer.CustNum.FIND Customer USING Customer.CustNum.
FIND Customer WHERE Customer.CustNum = INPUT Customer.CustNum.The CustNum field is a non-abbreviated index. However, consider this example:
PROMPT-FOR Customer.Name.FIND Customer USING Customer.CustName.
FIND Customer WHERE Customer.Name BEGINS INPUT Customer.Name.
DEFINE VARIABLE rid AS ROWID NO-UNDO.FIND FIRST Customer NO-LOCK.rid = ROWID(Customer).FIND Customer WHERE ROWID(Customer) = rid EXCLUSIVE-LOCK.When you read records with NO-LOCK, you have no guarantee of the overall consistency of those records because another user might be in the process of changing them. For example, when a record is updated, changes to indexed fields are written immediately, but changes to other fields are deferred. In the meantime, the record is in an inconsistent state. For example, the following procedure might display a CustNum of 0 if another user’s active transaction has created a record and assigned a value to the indexed field CustNum that is greater than 100:
FOR EACH Customer WHERE Customer.CustNum > 100 NO-LOCK:DISPLAY Customer.CustNum.END.
FIND Customer USING cust-name NO-ERROR NO-WAIT.Suppresses ABL errors or error messages that would otherwise occur and diverts them to the ERROR-STATUS system handle. If an error occurs, the action of the statement is not done and execution continues with the next statement. If the statement fails, any persistent side-effects of the statement are backed out. If the statement includes an expression that contains other executable elements, like methods, the work performed by these elements may or may not be done, depending on the order the AVM resolves the expression elements and the occurrence of the error.
Check if the ERROR-STATUS:NUM-MESSAGES attribute is greater than zero to see if the AVM generated error messages. ABL handle methods used in a block without a CATCH end block treat errors as warnings and do not raise ERROR, do not set the ERROR-STATUS:ERROR attribute, but do add messages to the ERROR-STATUS system handle. Therefore, this test is the better test for code using handle methods without CATCH end blocks. ABL handle methods used in a block with a CATCH end block raise ERROR and add messages to the error object generated by the AVM. In this case, the AVM does not update the ERROR-STATUS system handle.
Use ERROR-STATUS:GET-MESSAGE( message-num ) to retrieve a particular message, where message-num is 1 for the first message.
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.
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.
If a FIND statement fails, it indicates that the buffer named in record contains no record.
See the DEFINE BUFFER statement reference entry for a description of how to use FIND on a PRESELECTed set of records.
REPEAT:FIND NEXT Order.DISPLAY Order.SET Order.OrderNum.SET Order.OrderDate Order.PromiseDate.END.The AVM does an UNDO, RETRY if there is an error and you explicitly use the UNDO, RETRY statement, or if you press END-ERROR on the second or later windows interaction in a block.Here, if you press END-ERROR during the second SET statement, the AVM displays the next record in the table.
REPEAT:IF NOT RETRY THEN FIND NEXT Order.DISPLAY Order.SET Order.OrderNum.SET Order.OrderDate Order.PromiseDate.END.
FIND FIRST Customer.REPEAT:UPDATE Customer.FIND NEXT Customer.END.
FIND FIRST Customer.REPEAT:UPDATE Customer.FIND NEXT Customer NO-ERROR.IF NOT AVAILABLE Customer THEN LEAVE.
END.
FIND LAST Customer.RELEASE Customer.DISPLAY AVAILABLE Customer.REPEAT:FIND NEXT Customer.DISPLAY Customer.Name.END.
If you use FIND . . . WHERE ROWID rowid = . . . on a PRESELECTed list of records, the temporary preselect index cursor is not reset. So, FIND NEXT does not find the record that follows record rowid in the preselected list. (See the DO statement and REPEAT statement reference entries for details.)
When you run an ABL procedure, the AVM creates a cursor indicator for each index accessed through a FIND statement in the procedure and each NEW buffer defined in the procedure. A cursor indicator serves as an anchor for index cursors associated with a table or buffer. An index cursor is attached to the cursor indicator when you enter a block of code where a record buffer is scoped. If two different indexes are used for the same record buffer within a single block of code, two index cursors are attached to the same cursor indicator. When the program control leaves the block where a record buffer is scoped, all index cursors attached to the cursor indicator are released.
FOR EACH Customer NO-LOCK:FIND CURRENT Customer.END.
DO PRESELECT EACH Customer:FIND NEXT Customer NO-LOCK.END.
DO PRESELECT EACH Customer:FIND Customer 5.END.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |