Need count of records being populated

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
sengs
Participant
Posts: 55
Joined: Thu Nov 24, 2005 12:51 am

Need count of records being populated

Post by sengs »

Hi,
The job i designed generates a sequence number in the transformer stage.I want the total count of the sequence number in the target.
For example if the sequence number is from 1 to 10 then i want the count as 10 in the next stage.Help me in this regard.
Thanks,
Sengs
ravij
Premium Member
Premium Member
Posts: 170
Joined: Mon Oct 10, 2005 7:04 am
Location: India

Re: Need count of records being populated

Post by ravij »

Hi
You can do it using Agg stage. select count option in teh group by option. U will get the total count.
JRK
sengs wrote:Hi,
The job i designed generates a sequence number in the transformer stage.I want the total count of the sequence number in the target.
For example if the sequence number is from 1 to 10 then i want the count as 10 in the next stage.Help me in this regard.
Thanks,
Sengs
sengs
Participant
Posts: 55
Joined: Thu Nov 24, 2005 12:51 am

Re: Need count of records being populated

Post by sengs »

Hi ravi,
i tried using the aggregator.But it is also not giving me the total count.Instead it is giving me a sequence number like 1,2,3...10 again.
Thanks,
sengs
Andal
Participant
Posts: 124
Joined: Thu Dec 02, 2004 6:24 am
Location: Bangalore, India

Post by Andal »

Hi Sengs,

Your Question is not very clear.
If you generate the Sequence No's in a transformer, "@OUTROWNUM" will contain the count.
Rgds
Anand
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Re: Need count of records being populated

Post by loveojha2 »

sengs wrote:Hi ravi,
i tried using the aggregator.But it is also not giving me the total count.Instead it is giving me a sequence number like 1,2,3...10 again.
Thanks,
sengs
The input to the aggregator would be the sequence number, the ouput would be a single column with the derivation as the count().
Hi Sengs,

Your Question is not very clear.
If you generate the Sequence No's in a transformer, "@OUTROWNUM" will contain the count.
If you use @OUTROWNUM then your derivation would be max() for the @OUTROWNUM column.
Success consists of getting up just one more time than you fall.
jenkinsrob
Participant
Posts: 31
Joined: Mon Dec 01, 2003 6:24 am
Location: London

Post by jenkinsrob »

The quickest way is probably to use a hashed file.

Create 2 columns. Hard-code the first column with a value such as 'X' and make this the key column in your hashed file. Set the derivation for the other column in your transformer to @OUTROWNUM.

As the rows pass through the hashed file they will be de-duped based on the hard-coded key and you will be left with a single row containing the highest value that @OUTROWNUM reached ie your rowcount
tcj
Premium Member
Premium Member
Posts: 98
Joined: Tue Sep 07, 2004 6:57 pm
Location: QLD, Australia
Contact:

Post by tcj »

You want the max of the sequence number for each of the rows you pass through? :?
sengs
Participant
Posts: 55
Joined: Thu Nov 24, 2005 12:51 am

Re: Need count of records being populated

Post by sengs »

Hi Sengs,

Your Question is not very clear.
If you generate the Sequence No's in a transformer, "@OUTROWNUM" will contain the count.
If you use @OUTROWNUM then your derivation would be max() for the @OUTROWNUM column.[/quote]

Hi ravi,
i am generating the sequence number in the transformer stage by giving the derivation as @outrownum. But when i take max of @outrownum in the aggregator it still returns the value as 1,2,3,4.....N
My requirement is i want the value 'N' and i am using this value in an another sequence job.The value of 'N' will be differing every time when i run the job with certain parameter.
Thanks,
Senguttuvan
sengs
Participant
Posts: 55
Joined: Thu Nov 24, 2005 12:51 am

Post by sengs »

jenkinsrob wrote:The quickest way is probably to use a hashed file.

Create 2 columns. Hard-code the first column with a value such as 'X' and make this the key column in your hashed file. Set the derivation for the other column in your transformer to @OUTROWNUM.

As the rows pass through the hashed file they will be de-duped based on the hard-coded key and you will be left with a single row containing the highest value that @OUTROWNUM reached ie your rowcount
Hi ,
Can you please explain this with an example.I could not understand your statement "As the rows pass through the hashed file they will be de-duped based on the hard-coded key and you will be left with a single row containing the highest value that @OUTROWNUM reached ie your rowcount".
Thanks,
sengs
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

sengs wrote:
jenkinsrob wrote:The quickest way is probably to use a hashed file.

Create 2 columns. Hard-code the first column with a value such as 'X' and make this the key column in your hashed file. Set the derivation for the other column in your transformer to @OUTROWNUM.

As the rows pass through the hashed file they will be de-duped based on the hard-coded key and you will be left with a single row containing the highest value that @OUTROWNUM reached ie your rowcount
Hi ,
Can you please explain this with an example.I could not understand your statement "As the rows pass through the hashed file they will be de-duped based on the hard-coded key and you will be left with a single row containing the highest value that @OUTROWNUM reached ie your rowcount".
Thanks,
sengs
Since the key column is hard coded in the transformer(say with value 'X'), when first time it is written to Hashed File a row with 'X' as the primary key (and a non key column)would be created. Next time when it will again write another row with 'X' as the primary key (and other non key column)it will get overwritten (or in other word updated), since this column is the primary key.
Success consists of getting up just one more time than you fall.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Need count of records being populated

Post by ray.wurlod »

sengs wrote:Hi ravi,
i tried using the aggregator.But it is also not giving me the total count.Instead it is giving me a sequence number like 1,2,3...10 again.
Thanks,
sengs
You can not get the final count until the last row has been processed. Think about what happens.
Read the other suggestions (Transformer stage, Aggregator stage using Last, Aggregator stage using Count). All will work for you.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply