Progress
Language Reference


REPOSITION Statement

Interfaces
OS
SpeedScript
All
All
Yes

Repositions the cursor associated with a specific query. The query must be associated with a browse widget or defined with the SCROLLING option. The next record to be retrieved is the record following the cursor position.

SYNTAX

REPOSITION query 
  {     TO ROWID rowid1 [ , rowid2 ] ... [ NO-ERROR ] 
     |  TO RECID recid [ NO-ERROR ] 
     |  ROW n 
     |  FORWARDS n 
     |  BACKWARDS n 
  } 

query

The name of the query to reposition. The query must be open.

TO ROWID rowid1 [ , rowid2 ] ... [ NO-ERROR ]

Repositions the query to the join levels that correspond to the rowids you specify. rowid1 represents the rowid of the top level of join, rowid2 represents the rowid of the next level of join, etc. You can specify any number of rowids up to the number of join levels. If you specify fewer rowids than the number of join levels, Progress still repositions the query to the join levels that correspond to the rowids you specify, but arranges the remaining join levels arbitrarily.

NO-ERROR suppresses any error messages that result from specifying an illegal value or a value that does not identify any records returned by the query. To test whether an error occurred during a reposition operation, use the ERROR-STATUS handle.

TO RECID recid [ NO-ERROR ]

Similar to the TO ROWID option, except that the value recid is an expression that evaluates to a RECID value, and you can specify only one recid. Supported only for backward compatibility.

NO-ERROR suppresses any error messages that result from specifying an illegal value or a value that does not identify any records returned by the query. To test whether an error occurred during a reposition operation, use the ERROR-STATUS handle.

TO ROW n

Repositions the cursor to before the specified row in the result list of the query. The value n must be an INTEGER expression that identifies a row in the result list. You cannot use this option with a query opened with the INDEXED-REPOSITION option.

FORWARDS n

Moves the cursor from its current position in the result list to a new position n records forward, where n represents an INTEGER expression.

REPOSITION FORWARDS always places the cursor between two rows. For example:

BACKWARDS n

Moves the cursor from its current position in the result list to a new position n records back, where n represents an INTEGER expression.

REPOSITION BACKWARDS always places the cursor between two rows. For example:

EXAMPLE

The following example uses the REPOSITION statement to move forward or backward within a query.

r-repos.p
DEFINE QUERY  q-order FOR customer, order SCROLLING.
DEFINE BUTTON b_quit     LABEL "Quit".
DEFINE BUTTON b_frwd     LABEL "FORWARD".
DEFINE BUTTON b_back     LABEL "BACKWARD".
DEFINE VAR num AS INTEGER INIT 1 NO-UNDO.

FORM b_frwd b_back b_quit
  WITH FRAME butt-frame ROW 1.

ON CHOOSE OF b_back, b_frwd
DO:
  PROMPT-FOR num  LABEL "Records To Skip" 
    WITH FRAME pos-info CENTERED ROW 5 overlay.
  HIDE FRAME pos-info NO-PAUSE.
  IF SELF:LABEL = "BACKWARD" THEN
    REPOSITION q-order BACKWARDS INPUT num + 1.
  ELSE REPOSITION q-order FORWARDS INPUT num - 1.
  RUN getone.
END.

OPEN QUERY q-order FOR EACH customer,
  EACH order OF customer NO-LOCK.

RUN getone.

ENABLE b_back b_frwd b_quit WITH FRAME butt-frame.
WAIT-FOR CHOOSE OF b_quit OR WINDOW-CLOSE OF CURRENT-WINDOW.

PROCEDURE getone:
  GET NEXT q-order.
  IF NOT AVAILABLE(customer) THEN
  DO:
    REPOSITION q-order BACKWARDS 1.
    GET NEXT q-order.
  END.
  DISPLAY customer.cust-num customer.name skip
          order.order-num order.order-date
    WITH FRAME order-info CENTERED ROW 5 SIDE-LABELS OVERLAY.
END PROCEDURE. 

NOTES

SEE ALSO

CLOSE QUERY Statement, CURRENT-RESULT-ROW Function, DEFINE QUERY Statement, GET Statement, NUM-RESULTS Function, OPEN QUERY Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095