Page 1 of 1

for loop

Posted: Tue Aug 21, 2007 8:50 pm
by RAJEEV KATTA
Hi,

How do we use a for loop similar functionality in a parallel transformer.for loop similar functionality is available in server job transformer where in we give initial value in stage variables and condition in constraint which would serve the purpose same as for loop.But in parallel transformer this doesnot work,so is there any function which serves the same purpose.

Posted: Tue Aug 21, 2007 8:59 pm
by ArndW
The FOR-NEXT loop is not available in Server transform stages.

Please explain what you are trying to loop in a stage and someone might be able to think of a way to do this.

Posted: Tue Aug 21, 2007 9:16 pm
by ray.wurlod
You may be referring to a server routine invoked from a Transformer stage.

In a parallel routine you can also construct a loop. You just need C syntax for the loop (because a parallel routine is coded in C++). A parallel routine can be invoked from a parallel Transformer stage.

Posted: Tue Aug 21, 2007 9:20 pm
by RAJEEV KATTA
for next loop similar functionality is there in transformer.For example I want the no's from 1 to 10 in output what I do is first I'll take a stage variable i=0 and then in the transformer constraint I say i <11 and my ouput column is also stage variable i then all the values from 1 to 10 would be sent to output.How do I do the same operation in parallel transformer.

Posted: Tue Aug 21, 2007 9:39 pm
by ArndW
The stage variable and constraint method is identical in PX transformers, so you can do it exactly as you would in Server jobs.

Posted: Wed Aug 22, 2007 1:25 am
by wuv
RAJEEV KATTA wrote:for next loop similar functionality is there in transformer.For example I want the no's from 1 to 10 in output what I do is first I'll take a stage variable i=0 and then in the transformer constraint I say i <11 and my ouput column is also stage variable i then all the values from 1 to 10 would be sent to output.How do I do the same operation in parallel transformer.
You need a Row Generator stage. Just use a dummy column and limit the number of rows to 10, and link into the transformer. You can use the @OUTROWNUM for output.

Careful with the partitioning though. Simplest solution is to specify the two stages as "sequential".