Can .txt file contain null value?

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
Bicchu
Participant
Posts: 26
Joined: Sun Oct 03, 2010 10:49 pm
Location: India

Can .txt file contain null value?

Post by Bicchu »

Hi,

I am a newbee in datastage. I am trying to read a simple text file through a sequential file stage. Till now everything is working fine. My question is can a .txt file hold null value? If it contains I need to handle them.

I have searched other forums, there some one had mentioned that null values are not possible in .txt.

Can anybody please confirm?

Thanks in advance.

Thanks,
Pratik
Thanks,
Pratik.
MarkB
Premium Member
Premium Member
Posts: 95
Joined: Fri Oct 27, 2006 9:13 am

Post by MarkB »

Of course null values are possible in text files. As an example, you have a pipe-delimited text file with 4 columns .... you get data like:

1|A|B|C
2||D|E
3|F|G|H

On the second row, you have a null on the second column.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Actually, they're not. What you have in sequential files are empty fields rather than nulls.
-craig

"You can never have too many knives" -- Logan Nine Fingers
MarkB
Premium Member
Premium Member
Posts: 95
Joined: Fri Oct 27, 2006 9:13 am

Post by MarkB »

chulett wrote:Actually, they're not. What you have in sequential files are empty fields rather than nulls. ...
<sigh> Picky, picky,picky :wink:

True, they are empty fields, but when you are processing them into a transformer and writing them out you need to handle them as being null, which is what I believe the OP was worried about.
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

chulett wrote:Actually, they're not. What you have in sequential files are empty fields rather than nulls. ...
Craig,

You mean to say IsNull will not treat this field as NULL? I believe they do.
Arun
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Craig is correct. ISNULL() wont treat it as null. The ascii value for null and empty space are different.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Bicchu
Participant
Posts: 26
Joined: Sun Oct 03, 2010 10:49 pm
Location: India

Post by Bicchu »

I tried with ISNULL() but it is not working.
Thanks,
Pratik.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Whether or not an empty field is NULL depends on how you import it or modify it after importing.

1) Imported as a non-nullable varchar() field? It won't be null, it will be empty (Len = 0). make_null() with a modify stage, setNull() within a transformer to convert it to a true null (in a NULLABLE field). Simply changing the field to nullable will leave you with a nullable empty string...you must force it to a NULL.

2) Imported as a nullable varchar() field? I believe the default conversion is empty string to NULL, so it should be converted to a null. You can make sure by setting the appropriate NULL value in the Format Tab or metadata options.

3) Imported as a char()? Not recommended practice with a variable-length source field.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

My rule of thumb is, if I am working with an external FLAT file and I have to do null checks, I perform isnull() and len(trim()) < 1.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Text files don't really have data types at all (they just have text). Therefore it is not possible for them to contain null.

The Sequential File stage allows you to specify how "null" is represented in data, both globally and at the individual field level. This does not mean that null now exists in the text file, it means that the stage will interpret the Null Field Value value as null when encountered. The Null Field Value value does not have to be "".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
srinivas.nettalam
Participant
Posts: 134
Joined: Tue Jun 15, 2010 2:10 am
Location: Bangalore

Re: Can .txt file contain null value?

Post by srinivas.nettalam »

NULL means unknown value and empty means there is no value.A text file can have empty but it cannot have NULLs.if a field is empty or possible to be empty then select the option Null field value=''
and make the possible columns to NULL yes
N.Srinivas
India.
Post Reply