Finding number of rows in a seq file()

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
chitravallivenkat
Participant
Posts: 106
Joined: Thu Jun 08, 2006 8:51 am

Finding number of rows in a seq file()

Post by chitravallivenkat »

Hi All,

The job has an Inbound Sequential File connected to a Transformer. It needs to find the number of records in the file. If the file is empty i.e the number of rows is 0, I am not able to fetch the count and use for other validations.

Thanking you in advance
Vc
rachitha
Participant
Posts: 30
Joined: Wed Jun 28, 2006 10:53 am

hi

Post by rachitha »

hi

can you tell me how did you find the count of rows in the sequential file.

thanks in advance
rachitha.
chitravallivenkat
Participant
Posts: 106
Joined: Thu Jun 08, 2006 8:51 am

Post by chitravallivenkat »

we are using one routine for that....In that routine we will use the transform DSGetLinkInfo


Thanks

Vc
StageZilla
Participant
Posts: 15
Joined: Tue Nov 21, 2006 3:45 am
Location: WhiteField, Bangalore

Post by StageZilla »

Preload the count to zero, that should help
The quick brown fox jumps over the lazy dog.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

If the file is empty, then no rows were passed down the link. Is that right?
If you are using DSGetLinkInfo then you should get the row count i.e, DSJ.LINKROWCOUNT as 0
When you say you are not able to fetch the row count, do you get some errors/warning?
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Well, yes if you are trying to get the row count inside the transformer and if no rows come thorough it wont be instantiated and hence you wont get any validations done.
You need to handle this is before/after stage subroutine. Maybe test to see if file size is zero then do something.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:idea: Make sure you annotate this is happening on the canvas. Before/After job/stage routines are pretty much invisible to the neked eye. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

DSguru2B wrote:You need to handle this is before/after stage subroutine.
Right.

If we are using the routine as an After-job subroutine, I guess we can skip the test to check if the file is of zero size, before we can get the DSGetLinkInfo?
If no rows have passed through the link, we get the result as zero.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

narasimha wrote:If we are using the routine as an After-job subroutine, I guess we can skip the test to check if the file is of zero size, before we can get the DSGetLinkInfo?
If no rows have passed through the link, we get the result as zero.
Not really. Like the OP said, that he is doing some validations and getting rowcounts. Neither of those can be executed within the transformer without sending in a row. Thats why a file size check is necessary before the transformer gets executed (thats why a before stage routine and not a before job routine). The sub-routine will check if the size is 0 and will send out a zero thus sending something or doing something. That something can be whatever the OP wants.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Yes, I missed a few things here. :roll:
A check is required for size 0 or a DSJ.LINKROWCOUNT = 0 in the routine in this case.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
Post Reply