To check the output file rowcount
Moderators: chulett, rschirm, roy
To check the output file rowcount
Hi my target is a flat file.
I have to check whether any rows have been populated to the atrget file or not.
if there are no rows they I have to display an error message.
So after loading the data into a temporary file before loading into the target, i used a transformer to check the no. of rows going to the target.
in the constraint section I gave @INROWNUM=0 to display the error and if the INROWNUM <>0 then they data will be populated to the target.
But it is not working. Do we have any specific functions to check the row count.
Please throw a light on the same. We are using DS 7.1r1
I have to check whether any rows have been populated to the atrget file or not.
if there are no rows they I have to display an error message.
So after loading the data into a temporary file before loading into the target, i used a transformer to check the no. of rows going to the target.
in the constraint section I gave @INROWNUM=0 to display the error and if the INROWNUM <>0 then they data will be populated to the target.
But it is not working. Do we have any specific functions to check the row count.
Please throw a light on the same. We are using DS 7.1r1
Thanks,
Madhavi
Madhavi
You'll never have a row go into an output link which requires a constraint check if there's no input rows. Your method doesn't work. Use an after-stage routine call and write a routine that checks the link values using the API libraries.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Can u please tell me how to do that. I dont have idea on API libraries.kcbland wrote:You'll never have a row go into an output link which requires a constraint check if there's no input rows. Your method doesn't work. Use an after-stage routine call and write a routine that checks the link values using the API libraries.
Thanks,
Madhavi
Madhavi
This forum has thousands of posts regarding doing what you ask, just use the Search. Your DS BASIC manual is available under your Start button.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
chulett wrote:Search for DSGetLinkInfo as a starting point. ...
The flow of job is as follows:
Source->Transformer1-->Transformer2-->Target
Now i need to check if the target is empty or it has rows.
if there's no data coming to the target flat file then it has to display the error message.
I created the routine called Countrows for DSGetLinkInfo as suggested.
I extended the job with one more transformer connected to the target file. I used this routine inside the transformer to find out the number of rows coming out of the target file.
If the target is empty, I dont know whether it will go to the next stage ie transformer to run the routine and get the number of rows.
I tried running the routine for an empty target file and tried diplaying the eror message if the routine returns no rows.
but it is not working. I was not successful in waht I have done. I dont know how it check the emptyness of a file or size of a file.
Pls help me out.
Thanks,
Madhavi
Madhavi
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The number of bytes in a file is returned by the STATUS statement applied to the file variable associated with an opened file. In your case, since it's an operating system file in which you are interested, you would have opened it with OPENSEQ, and will close it with CLOSESEQ.
This has been described very recently on the forum. You would apply this test in an after job or after stage subroutine (using DSLogWarn to log a warning message), or in a Routine activity after the job had been completed (using a downstream Routine activity to invoke UtilityWarningToLog).
Plan exactly what you want to do in the circumstance that the file is empty, and you can implement precisely that plan.
This has been described very recently on the forum. You would apply this test in an after job or after stage subroutine (using DSLogWarn to log a warning message), or in a Routine activity after the job had been completed (using a downstream Routine activity to invoke UtilityWarningToLog).
Plan exactly what you want to do in the circumstance that the file is empty, and you can implement precisely that plan.
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.
The code in the routine is as follows:chulett wrote:Post your routine code. Plus I'd suggest you think about doing this 'post job' as in a Sequence job or possibly after job. It depends on exactly what you mean by 'display an error' if the processed row count is zero.
DSGetLinkInfo(DSJ.ME,StageName','linkname', DSJ.LINKROWCOUNT)
when I check the routine in DS manager it is returning -1.
I did not use any code to open the file like OPENSEQ.
My requirement is if there are rows they have to be populated and if tehre are no rows, the error message has to be written to the same target file, as the user doesn't want it to be in two seperate files.
Flow from temp target:
temp file--> transformer--> Actual target
in the transformer if i call the routine, i feel it not working properly because if there are no rows in the temp file, the flow is not proceeding to the next stage.
Thanks,
Madhavi
Madhavi
1.It's giving error in the Manager because you need to give JobHandle in place of DSJ.ME. You would need to attach the Job first using DSAttachJob to get the JobHandle and then use the JobHandle in your code.pmadhavi wrote:
The code in the routine is as follows:
DSGetLinkInfo(DSJ.ME,StageName','linkname', DSJ.LINKROWCOUNT)
when I check the routine in DS manager it is returning -1.
2. If would like to use DSGetLinkInfo in a transformer stage you might want to design a job something like this
Code: Select all
Source->Transformer1--Tempfile>Transformer2-->Target
Code: Select all
Source->Transformer1-->Transformer2-->Target
Now in the second Transformer, you can define a stage variable which can read the number of rows passed into Temp file and based upon that you can write messages to log using DSTransform or to the output file.
IHTH
Kris
Where's the "Any" key?-Homer Simpson
Where's the "Any" key?-Homer Simpson
Ray suggested OPENSEQ if you want to use the STATUS command. This command will tell you if your file is of zero bytes or not. But you want to get the row count on a particular link using DS functions. So basically you dont need OPENSEQ command.pmadhavi wrote:I did not use any code to open the file like OPENSEQ.
My advice, do it in seperate jobs. Dont do all this in the same job. Build your Temp file. Then in your second job you can get the row count of that particular link and do what you have to do with it.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.