One Star

Creates empty file

Hi,
Talend job creates empty file even after the tDie component triggered.
DBComponent --------->tFileDelimitedOutput
|
onComponentError
|
tDie

DBComponent has a custom query. Sometimes, it can not find a table/column defined in the query. In this case, the job has to abort and should not create an empty file. On the other hand it should create an empty file if the query gives zero records.
The above job handling the second scenario correctly. However, its still creating an empty file, after the query fails because of some error.
Please let me know, if I am missing anything.
Thank you,
Sangi
4 REPLIES
Seventeen Stars

Re: Creates empty file

Change in the advanced section the option Don'r generate empty file.
The problem is, the file and it handle will be created first and after that your query will be executed.
In this way, the file will be created and if no data set reach the file, the file will be automatically deleted.
One Star

Re: Creates empty file

Hi,
Thanks for the reply.
I can not use 'Don't create empty file' because we need an empty file when the query in dbcomponent gives zero records.
Regards,
sangi
Seventeen Stars

Re: Creates empty file

At first please use OnSubjobError instead of OnComponentError and after OnSubjoberror you can decide to delete your file at first and then call tDie to end the job.
One Star

Re: Creates empty file

Hi,
Thank you for your time.
I have used the following job and its working fine.
DBComponent --------->tFileDelimitedOutput
|
onComponentError
|
tFileDelete (deleting the same which is created in tFileDelimitedOutput)
|
onComponentOk
|
tDie
Jlolling, if you have time. Can you please let me know whats the exact difference in using onComponentError and onSubjobError in this scenario?
Regards,
Shankar