Row Counter
Moderators: chulett, rschirm, roy
Row Counter
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
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
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 385
- Joined: Wed Jun 16, 2004 12:43 pm
- Location: Virginia, USA
- Contact:
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.
Chuck Smith
www.anotheritco.com
www.anotheritco.com
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
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.
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.
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn