PreviousNextIndex

DO statement

Groups statements into a single block, optionally specifying processing services or block properties. Use an END statement to end a DO block.

Syntax

[ label : ] 
DO 
  { [ FOR record [ , record ] ... ] } 
  [ preselect-phrase ] 
  [ query-tuning-phrase ] 
  [ variable = expression1 TO expression2 [ BY k ] ] 
  [ WHILE expression ] 
  [ TRANSACTION ]  
  [ STOP-AFTER expression ] 
  [ on-endkey-phrase ] 
  [ on-error-phrase ] 
  [ on-quit-phrase ] 
  [ on-stop-phrase ] 
  { [ frame-phrase ] } : 
  do-body 

FOR record [ , record ] ...
preselect-phrase
query-tuning-phrase
variable = expression1 TO expression2 [ BY k ]
WHILE expression
TRANSACTION
STOP-AFTER expression
on-endkey-phrase
on-error-phrase
on-quit-phrase
on-stop-phrase
frame-phrase
do-body
do-logic
catch-block
finally-block
END
Example

This procedure goes through the Customer table and, for those Customers whose CreditLimit is over 80000, reduces CreditLimit to 80000. The procedure uses an unmodified DO block to process two statements if CreditLimit is over 80000. Unmodified DO blocks are most useful in conditional, or IF. . .THEN. . .ELSE situations.

r-do.p
FOR EACH Customer NO-LOCK: 
  DISPLAY Customer.Name Customer.CreditLimit. 
  PAUSE 3. 
  IF Customer.CreditLimit > 80000 THEN DO: 
    Customer.CreditLimit = 80000. 
    DISPLAY Customer.Name Customer.CreditLimit. 
  END. 
END. 

Notes
See also

CATCH statement, FINALLY statement, FIND statement, FOR statement, Frame phrase, ON ENDKEY phrase, ON ERROR phrase, ON QUIT phrase, ON STOP phrase, Record phrase, REPEAT statement


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex