Testing for empty file condition in Server Job
Moderators: chulett, rschirm, roy
Testing for empty file condition in Server Job
I have a server job which reads .csv file and load into db2 database through transformer. Now, once in a while we are getting empty file from Sales department. Can we use a function/condition by which if the file has zero data , the job will abort.
The load process look like this,
sequential--transformer--hashed--database
Appreciate your help.
The load process look like this,
sequential--transformer--hashed--database
Appreciate your help.
The job itself won't care and will happily process an empty file. However, because no rows are flowing through the job you can't use a condition inside the job to abort it.
What Andy posted is cleanest and makes what is going on much more obvious / visible to the casual observer. You could do something 'Before Job' (a O/S script, or a BASIC routine) to test the size of the file and abort the job before it starts but that's much less visible... unless you put an Annotation on the canvas noting what is going on there.
What Andy posted is cleanest and makes what is going on much more obvious / visible to the casual observer. You could do something 'Before Job' (a O/S script, or a BASIC routine) to test the size of the file and abort the job before it starts but that's much less visible... unless you put an Annotation on the canvas noting what is going on there.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Thanks a lot
Thanks a lot everyone. let me try executing the commands. The problem is, we can't have the sequencer for this job. In job control we can specify a code which will tell us that the job failed for the first job in Job control and other jobs will not run. But load actually finishes even though file is empty.
But this job has a process control which triggers our reporting. If file will zero data finishes then process control triggers the wrong report. Basically, have to do something by which, the Load itself will abort if the file has zero record so our process control does not update and report will not run.
But this job has a process control which triggers our reporting. If file will zero data finishes then process control triggers the wrong report. Basically, have to do something by which, the Load itself will abort if the file has zero record so our process control does not update and report will not run.
On Windows? Hmm... UNIX would be trivial but it's harder in a batch file. Try googling for something like "DOS test file size" and code samples should turn up. As Ray noted, all you'd have to do is pass back a non-zero exit code from the batch in that case for the job to notice and abort.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
As noted, lots of DOS help out there. Here's one I found with a quick search:
http://www.dostips.com/?t=Snippets.ZeroBytesCheck
http://www.dostips.com/?t=Snippets.ZeroBytesCheck
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers