count of the column by using loop variables
Moderators: chulett, rschirm, roy
count of the column by using loop variables
Hi,
I want to caclulate count of the column by useing loop variables in transformer.
select count(col1) from the table.
But i am getting 5000 rows out of 10000.
Defined the following stage variables:
NumSavedRows
SaveInputRecord()
IsBreak
LastRow()
NumRows
IF IsBreak THEN NumSavedRows ELSE 0
Defined the following loop variable:
SavedRowIndex
GetSavedInputRecord()
Loop condition:
@ITERATION <= NumRows
Define the output link columns and their derivations:
Col1 - NumRows
I want to caclulate count of the column by useing loop variables in transformer.
select count(col1) from the table.
But i am getting 5000 rows out of 10000.
Defined the following stage variables:
NumSavedRows
SaveInputRecord()
IsBreak
LastRow()
NumRows
IF IsBreak THEN NumSavedRows ELSE 0
Defined the following loop variable:
SavedRowIndex
GetSavedInputRecord()
Loop condition:
@ITERATION <= NumRows
Define the output link columns and their derivations:
Col1 - NumRows
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Re: count of the column by useing loop variables
Why would you need to advance passed this if all you want is the count?iskapalli wrote: I want to caclulate count of the column by useing loop variables in transformer.
select count(col1) from the table.
If you aren't using the input record, why save it?iskapalli wrote: Defined the following stage variables:
NumSavedRows
SaveInputRecord()
Define the output link columns and their derivations:
Col1 - NumRows
Is there a requirement behind what you are doing or practising the use of looping?
So you only want the last row of data? Just have a LastRow() condition on the output stream, run in sequential mode and sort your input... or better than that, make sure you only retrieve the row you want.
Looping is only required when you want one row to produce multiple rows so unless there is something missing in your requirement, I don't see what it is.
Looping is only required when you want one row to produce multiple rows so unless there is something missing in your requirement, I don't see what it is.
-
- Premium Member
- Posts: 1044
- Joined: Wed Sep 29, 2004 3:30 am
- Location: Nottingham, UK
- Contact:
Loop variables are not for counting the number of rows - Loops replicate the input row a number of times on the output link, and Loop Variables are evaluated for each copy of the input row that is generated.
To count the number of rows, feed your stream through an Aggregator.
And if you really want ot do it with a Loop Variable... well, don't. That's not a sensible thing to want to do. It's like wanting to drive across a river. Sure, if you go fast enough you might make it, but the only sane solution is to use a bridge or a ferry.
To count the number of rows, feed your stream through an Aggregator.
And if you really want ot do it with a Loop Variable... well, don't. That's not a sensible thing to want to do. It's like wanting to drive across a river. Sure, if you go fast enough you might make it, but the only sane solution is to use a bridge or a ferry.
Phil Hibbs | Capgemini
Technical Consultant
Technical Consultant
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You could also wait for a drought.
Meantime you can count in a Transformer stage using stage variables.
As noted, Loop variables are not the correct mechanism. Use a Loop variable for processing things within a field (though counts of those can probably more easily be obtained with functions like Count() or DCount()).
Meantime you can count in a Transformer stage using stage variables.
As noted, Loop variables are not the correct mechanism. Use a Loop variable for processing things within a field (though counts of those can probably more easily be obtained with functions like Count() or DCount()).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: