Null & Blank

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
dssiddu
Participant
Posts: 66
Joined: Mon Nov 07, 2005 10:28 pm
Contact:

Null & Blank

Post by dssiddu »

hi

can any one tell me the differance between Null & Blank?

And How will we check in DataStage?

For Blank we have to use '' or ""


Adv Thks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What you are calling 'blank' is an 'empty string' and is a known value. Null is the unknown value and is tested for using the IsNull function.
-craig

"You can never have too many knives" -- Logan Nine Fingers
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Re: Null & Blank

Post by PhilHibbs »

dssiddu wrote: can any one tell me the differance between Null & Blank?
And How will we check in DataStage?
For Blank we have to use '' or ""
The confusion arises because, by default, DataStage treats a blank value in a Sequential File as a null.

@NULL techincally means "unknown", which is why you lose your information if you concatenate a null field value with a string. Also any comparison (e.g. "DSLink1.Value <> 42" will return @FALSE if Value is a null.

There are two ways around this - either change the properties of your Sequential File stages so that @NULL is represented by a value of your choosing, just live with it. We have so many jobs with so many Sequential File stages that I concluded that the first approach was doomed to failure since someone is bound to forget to set the property correctly, so I wrote a simple transform called CoStr which returns either the first parameter or the second if the first is @NULL, so CoStr(DSLink1.Value,'') returns a blank string if Value is null. Where it matters, we code around the @NULL problem.
Phil Hibbs | Capgemini
Technical Consultant
ketfos
Participant
Posts: 562
Joined: Mon May 03, 2004 8:58 pm
Location: san francisco
Contact:

Post by ketfos »

Hi Phil,

Can your share your function of handling nulls in seq file?

Thks
Ketfos
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

On the Format tab there's a property in which you can specify how null is represented in the text file. By default this field is empty, which means that "" (a zero-length string) is treated as null. Change it to anything else (such as <NULL>) and you will read "" as "".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

ketfos wrote:Hi Phil,
Can your share your function of handling nulls in seq file?
Thks
Ketfos
Sure, it's at http://www.hibbs.me.uk/datastage/CoStr.dsx

The "Co" is short for "Coalesce", which is an SQL function that serves a similar purpose, and "Srt" stands for "String", because transforms have to have a return type so I thought I'd start a namespace for "CoInt" etc. which I never needed.
Phil Hibbs | Capgemini
Technical Consultant
Post Reply