Sequential stage should create file only when records exist

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
news78
Participant
Posts: 44
Joined: Fri Jul 07, 2006 1:37 pm

Sequential stage should create file only when records exist

Post by news78 »

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
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

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
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post by ds_developer »

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 »

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 »

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
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

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. :wink:
-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 »

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 »

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#
Post Reply