Skip to content

iterate

jeremywinters edited this page Apr 15, 2017 · 2 revisions

Command: ITERATE

description:

iterates through every record of a named recordset that has been stored in memory. the SQL statement in the tag will be executed once for every record in the recordset. the fields of the current record can be accessed in the format:

:recordset.field

parameters:

  • required - recordset name
  • optional - series of conditional expressions using syntax include|exclude recordset_field operator expression (see example below)

behavior:

  • recordset will be iterated
  • query will be executed once for every record in the set
  • references to record values will be evaluated before query is executed
  • stores (and overwrites) 'last_statement_rows_affected' variable, but this behavior may be inconsistent when running multiple SQL statements

examples:

/*-iterate rs-*/
insert into some_table(f, g) values (:rs.a, :rs.b);

/*-iterate rs- include a = 2 exclude b > 5 */
insert into some_table(f, g) values (:rs.a, :rs.b);