Coulmn name in file

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
nani0907
Participant
Posts: 155
Joined: Wed Apr 18, 2007 10:30 am

Coulmn name in file

Post by nani0907 »

Hi all,

I need to populate the column name if the it has values .else no values has present then empty file should be created. By setting the option in sequential file for column names first= true doesnot help me as if there are no values,only column name is generated. Could any body help me how to achieved this by derivations.
thanks n regards
nani
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

please try to be very clear on your requirement.
do you mean if there are no record then empty file should be generated else the first row should be the column names??
nani0907
Participant
Posts: 155
Joined: Wed Apr 18, 2007 10:30 am

Post by nani0907 »

If there are no records then empty files should be generated.

if we have records then we should aslo pupulate column names along with records.


Thanks
thanks n regards
nani
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Out of the box... you don't get conditional column headers. If that's your requirement, you have to design and code it yourself...

Mike
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

OK , Create two files in the job, one file for only header records with column names only, another file with records only and then in after job subroutine, append the second file into first file.
nani0907
Participant
Posts: 155
Joined: Wed Apr 18, 2007 10:30 am

Post by nani0907 »

If there are no values in second file, the first file will populate the column names.but my case is that if no records, column names also should not be created.
thanks n regards
nani
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

that was just an idea.
you can have a condition , if second file size is greater then Zero then only append. Else delete the first file and then touch <file name>
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Lots of potential ways to skin that cat. An easy one that comes to mind is to "after job" count the lines in the file and if the count is one (i.e. headers only), then empty it out.

Mike
mk_ds09
Participant
Posts: 72
Joined: Sun Jan 25, 2009 4:50 pm
Location: Pune

Post by mk_ds09 »

One more way you can achieve that is.
in properties set column names 'yes', it will give you column names in the output file.

In after job subroutine.
If wc -l output <= 1 then touch output_file.

that will create empty file if there is only one record with the columns.

hope this helps..

----------------
MK
Post Reply