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
news78
Participant
Posts: 44 Joined: Fri Jul 07, 2006 1:37 pm
Post
by news78 » Thu Aug 02, 2007 1:59 pm
My job design is as follows:
[DRDBMS Stage] > [Transformer] > [Sequential file]
Currently it creates a file of 0 size even if there are no records returned from the query. But I want the sequential file to be created only when there are records returned from database or else no file should be created.
This should be really simple. I did a quick check on the forums but didnt turn up anything. Please advice. Thanks!
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Thu Aug 02, 2007 2:25 pm
Doesn't work that way - it will always create the file.
-craig
"You can never have too many knives" -- Logan Nine Fingers
ds_developer
Premium Member
Posts: 224 Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA
Post
by ds_developer » Thu Aug 02, 2007 2:34 pm
You could perform something in an After-job subroutine to delete the file if it has 0 bytes.
John
news78
Participant
Posts: 44 Joined: Fri Jul 07, 2006 1:37 pm
Post
by news78 » Thu Aug 02, 2007 2:34 pm
chulett wrote: Doesn't work that way - it will always create the file. ...
OK. So I guess I have to write some kind of after job routine whihc will delete the file if no row exists.
BTW, what does "Turtles all the way down" mean in your signature?
news78
Participant
Posts: 44 Joined: Fri Jul 07, 2006 1:37 pm
Post
by news78 » Thu Aug 02, 2007 2:38 pm
news78 wrote: chulett wrote: Doesn't work that way - it will always create the file. ...
OK. So I guess I have to write some kind of after job routine whihc will delete the file if no row exists.
BTW, what does "Turtles all the way down" mean in your signature?
Nev mind, I checked the wikipidea.
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Thu Aug 02, 2007 2:41 pm
That's probably the best approach. Another is a 'pre-check' and then skip running the job if the query returns zero records. Personally, zero byte files don't bother me in the least.
-craig
"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607 Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:
Post
by ray.wurlod » Thu Aug 02, 2007 3:05 pm
Code: Select all
test -z #pathname# && rm #pathname#
handed to ExecSH as an after-job subroutine.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
news78
Participant
Posts: 44 Joined: Fri Jul 07, 2006 1:37 pm
Post
by news78 » Fri Aug 03, 2007 1:12 pm
ray.wurlod wrote: Code: Select all
test -z #pathname# && rm #pathname#
handed to ExecSH as an after-job subroutine. ...
This worked for me:
Code: Select all
test ! -s #pathname# && /bin/rm -f #pathname#