Loop example: generating new rows (DataStage®)

You can use the Transformer stage to generate new rows, based on the value of a column in the input row.

Value in an input row column used to generate new output rows

You can use the Transformer stage to generate new rows, based on values held in an input column.
For example, you have an input column that contains a count, and want to generate output rows based on the value of the count. The following example column has a count value of 5.
Col1 Col2 MaxCount
abc def 5
You can generate five output rows for this one input row based on the value in the Count column.
Col1 Col2 EntryNumber
abc def 1
abc def 2
abc def 3
abc def 4
abc def 5
To implement this scenario in the Transformer stage, make the following settings:
Loop condition
Enter the following expression as the loop condition:
@ITERATION <= inlink.MaxCount
For each input row, the loop iterates the number of times defined by the value of the MaxCount column.
Output link metadata and derivations
Define the output link columns and their derivations:
  • Col1 - inlink.Col1
  • Col2 - inlink.Col2
  • EntryNumber - @ITERATION