REPOSITION

How to:

Reference:

For a specified segment and each of its descendants, the REPOSITION command resets the current position to the beginning of chain for that segment. That is, each segment is reset to just prior to the first instance.

Most data source commands change the current segment position to the instance that they most recently accessed. To search an entire data source or path for records, start at the beginning of the data source or path by first issuing the REPOSITION command.

Syntax: How to Use the REPOSITION Command

The syntax of the REPOSITION command is

REPOSITION segment_spec [;]

where:

segment_spec

Is the name of a segment or the name of a field in a segment. The specified segment and all of its descendants are repositioned to the beginning of the segment chain.

;

Terminates the command. Although the semicolon is optional, you should include it to allow for flexible syntax and better processing. For more information about the benefits of including the semicolon, see Terminating a Command's Syntax.

Example: Using REPOSITION

The following example repositions the root segment and all of the descendant segments of the Employee data source:

REPOSITION Emp_ID;

The next example repositions both the SalInfo and Deduct segments in the Employee data source:

REPOSITION Pay_Date;

Reference: Commands Related to REPOSITION

  • NEXT. Starts at the current position and moves forward through the data source and can retrieve data from one or more records.
  • MATCH. Searches entire segments for a matching field value and can retrieve an exact match in the data source.