Row Counter

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
kalkavi
Participant
Posts: 11
Joined: Tue Aug 17, 2004 7:42 am
Contact:

Row Counter

Post by kalkavi »

Hi,

I'm new to Datastage. All the time i was working in cobol and we are used to increment the variables and use them in control reports. Can we build something in datastage similar to that where we can increment a variable and use the vairable to write a control report. Please let me know if this is confusing.

Thanks for the help
Kalyan
KeithM
Participant
Posts: 61
Joined: Thu Apr 22, 2004 11:34 am
Contact:

Post by KeithM »

Datastage does provide some system variable that may give you what you are looking for. @InRowNum and @OutRowNum will give you a count of the number of rows that come in and exit your process. You can also do it on your own using stage variables. If you have more detail on what you are trying to accomplish this forum could probably provide a better answer for you.
Keith
kalkavi
Participant
Posts: 11
Joined: Tue Aug 17, 2004 7:42 am
Contact:

Post by kalkavi »

We have three load odbc stages. At the end of the job i need to write a control report which should show # of rows loaded in stage1 , stage2 stage3.

Thanks for the help
Kalyan
kalkavi
Participant
Posts: 11
Joined: Tue Aug 17, 2004 7:42 am
Contact:

Post by kalkavi »

I tried using system variables. But the problem with that is counter is being added for each record. It does not summarize the value.

Thanks
Kalyan
KeithM
Participant
Posts: 61
Joined: Thu Apr 22, 2004 11:34 am
Contact:

Post by KeithM »

You could do it by inserting a hash file into your process. You would write a record out to the hash for each or your three output stages. The key would be a constant indicating either stage1, 2, or 3 and you would have a count field which you could populate with @OutRowNum. Then everytime it writes a record out it will also update the hash with the current record count. At the end the hash will contain the last record number which is also the count of the number of records written. Just be sure to have caching turned off on the hash file so that it gets updated for each record written.
Keith
dhiraj
Participant
Posts: 68
Joined: Sat Dec 06, 2003 7:03 am

Post by dhiraj »

How are you generating that control report?

are you using a basic routine for that? if so i guess u can use dsgetloginfo() to get the number of records written to each link(odbc). Look in to the documentation for more info.

Dhiraj
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The link row counts are directly accessible using DSGetLinkInfo() function.

Code: Select all

RowCount = DSGetLinkInfo(hJob, StageName, LinkName, DSJ.LINKROWCOUNT)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chucksmith
Premium Member
Premium Member
Posts: 385
Joined: Wed Jun 16, 2004 12:43 pm
Location: Virginia, USA
Contact:

Post by chucksmith »

If you want to do this in your job, then pass @OUTROWNUM from your transform into an aggregator. In the aggregator, use the LAST derivation. Finally, connect the aggregator to your ODBC stage. If required, place a transform between the aggregator and ODBC stage.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

I think Ray's approach is better, wait until the job has finished and then go and get the link counts. There is no point doing row counting from within the job, it is inefficient as you are counting for each row instead of counting just once, and it is difficult to write out.

There is example code on Ascential devnet submitted by Kim Duke that shows how to pull job stats via routines for the type of job reporting you are looking for.
Post Reply