Loop Dataset Action Icon

Loop Dataset Action

Declaration

<AMLOOPDATASET DATASET="text" FROM="number" TO="number">
  (block of steps to loop)
</AMLOOP>

See Also

Loop, End Loop, Loop Files, Loop Windows, Loop Processes, Loop Expression, Loop List, Break

Description

Loops through the rows of the dataset specified. With each successive loop a block of steps is executed and the current row of the dataset is incremented. The loop ends when at the end of the dataset or when a Break is encountered.

Practical Usage

To loop a block of steps through the records (rows) in a dataset (which is a multicolumn, multirow variable). With each loop the current record (row) in the dataset is incremented, until the last record is reached at which point the loop is ended.

Parameters

General Tab

Dataset Name
Text, Required
MARKUP: DATASET="DATASETNAME"

Specifies the name of a previously created dataset. Example actions that create datasets are SQL Query, POP3 Mail, and Stored Procedure.

Start Row
Number, Optional Default - 0
MARKUP: FROM="20"

Specifies the record (row) to start on when moving through the dataset.

End Row
Number, Optional - Default 0
MARKUP: STEP="2"

Specifies the record (row) to stop on when moving through the dataset. If omitted or set to 0 the End Row is the last in the dataset.

Notes

Standard Error Handling Options
This action also includes the standard "Error Causes" and "On Error" failure handling options/tabs

More on Error Handling Options

Variables and Expressions
All text fields allow the use of expressions by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, a popup expression builder is available in all these fields by pressing F2.
More on variables...

More on expressions...

More on the expression builder...

Examples

<!-- The following task executes a SQL query which populates a dataset called CUSTOMERLIST It then loops through that dataset and writes the values to a file record by record --->
<AMSQLQUERY CONNECTIONSTRING="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=username;Initial Catalog=testdata;Data Source=SERVER" DATASETRESULT="CUSTOMERLIST" SQLSTATEMENT="SELECT FIRSTNAME, LASTNAME FROM CUSTOMERS WHERE CITY='LOS ANGELES';">
<AMLOOPDATASET DATASET="CUSTOMERLIST">
  <AMFILEWRITE FILE="c:\customerlist.txt" WRITEDATA="!!CUSTOMERLIST.FIRSTNAME!! !!CUSTOMERLIST.LASTNAME!!">
</AMLOOP>