Page 1 of 1

Sequential stage should create file only when records exist

Posted: Thu Aug 02, 2007 1:59 pm
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!

Posted: Thu Aug 02, 2007 2:25 pm
by chulett
Doesn't work that way - it will always create the file.

Posted: Thu Aug 02, 2007 2:34 pm
by ds_developer
You could perform something in an After-job subroutine to delete the file if it has 0 bytes.

John

Posted: Thu Aug 02, 2007 2:34 pm
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?

Posted: Thu Aug 02, 2007 2:38 pm
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. :)

Posted: Thu Aug 02, 2007 2:41 pm
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:

Posted: Thu Aug 02, 2007 3:05 pm
by ray.wurlod

Code: Select all

test -z #pathname# && rm #pathname#
handed to ExecSH as an after-job subroutine.

Posted: Fri Aug 03, 2007 1:12 pm
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#