Page 1 of 1

How are empty fields better handled

Posted: Wed Oct 26, 2011 1:55 pm
by Nsg
Hi all,

While formating fields for my target seqencial file, I came up with multiple ways of handling fields that are empty and passing default values for those fields.
Following are the ways I thought of, but am not sure if DataStage interprets them the same way and if all ways are equally effecient (or otherwise)

1) Extract those fields as Character and non nullable and thus it passes 'spaces' for fields that are empty and then in transformer do and "If ' ' Then '9999' Else <Field_Value>"

2) Extract all fields as Varchar and nullable and then using NullToValue(<Field_Value>, '9999') in transformer.

Please let me know if any one of this is a preffered method over other?

Thanks,
nsg

Posted: Wed Oct 26, 2011 7:43 pm
by ray.wurlod
Neither is preferred, though I suspect the VarChar one may be slightly more efficient.

Re: How are empty fields better handled

Posted: Wed Oct 26, 2011 7:46 pm
by djbarham
If the source is a database, then I'd make the input match the database specification which probably means varchar and nullable.

The way I see it, you have 2 choices, but they relate to how you output the data.

You sequential file stage has built in capability to handle nulls. You can use this.

Alternatively, you can simply use NullToValue(inputfield , defaultvalue) in your transformer stage.

I have tended to use the latter because I was too lazy to get my head around how the sequential file stage handles nulls.