AMT Help Files

LOOP (query handler)

Syntax

Command
Mandatory parameter
Optional parameter
Mandatory keyword
Optional keyword

LOOP <Query handler>

    <Code lines>

ENDLOOP

Description

Does an implicit SQL query execute and then loops through the result set. Repeats execution of the enclosed code lines for each record. This means the first record of the result set will be fetched before the loop is executed the first time and then the next record before the each next loop. The loop will end when the last record of the result set has been fetched and the loop code has been executed.

Diagram

Returned value type

None

Parameters

Parameter Description
<Query handler>
The name of the Table Query, Query or Stored Procedure handler to execute
<Code lines>
Code that is performed each time the loop is executed. The loop will be terminated in one of the following cases:
  • When a BREAK command is encountered
  • When a GOTO command is encountered that refers to a label outside the loop.
  • When an EXIT command is encountered. This command jumps out of the current routine and therefore it exits the LOOP also.

Example


q_ccdemdet.index (proccdemdet)
q_ccdemdet.equal (lijndcode)
q_ccdemdet.start (reisnr'')
q_ccdemdet.where (q_ccdemdet.openstaand = True)
loop q_ccdemdet
    if reisnr <> '' and reisnr <> q_ccdemdet.reisnr then bk
        add_container ()
endloop