Page 1 of 1

Finding number of rows in a seq file()

Posted: Mon Nov 27, 2006 5:28 am
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

hi

Posted: Mon Nov 27, 2006 6:56 am
by rachitha
hi

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

thanks in advance
rachitha.

Posted: Mon Nov 27, 2006 6:58 am
by chitravallivenkat
we are using one routine for that....In that routine we will use the transform DSGetLinkInfo


Thanks

Vc

Posted: Mon Nov 27, 2006 8:41 am
by StageZilla
Preload the count to zero, that should help

Posted: Mon Nov 27, 2006 1:01 pm
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?

Posted: Mon Nov 27, 2006 1:06 pm
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.

Posted: Mon Nov 27, 2006 1:19 pm
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:

Posted: Mon Nov 27, 2006 1:32 pm
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.

Posted: Mon Nov 27, 2006 1:36 pm
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.

Posted: Mon Nov 27, 2006 4:43 pm
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.