Checking for Null value

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
sankar18
Participant
Posts: 34
Joined: Mon Dec 16, 2002 1:18 am

Post by sankar18 »

For Null reject rows
--------------------
In Constraint field,

Len(Trim(column))0

T Sankar



Edited by - sankar18 on 12/17/2002 06:35:31
msigal
Participant
Posts: 31
Joined: Tue Nov 26, 2002 3:19 pm
Location: Denver Metro

Post by msigal »

My experience with Null data is that the transformer converts it to spaces (making sankar18's suggestion work well). But when written out to a sequential file the null will be written, not a space. If spaces are ok to pass and nulls aren't you'll need to check for the null with a custom routine. When you pass the column to the routine, the routine will recognize the null values. If you need to check for nulls byte by byte you can use the Seq() function in your routine.

Myles Sigal
Technical Analyst
The MEDSTAT Group
777 E. Eisenhower - 435B
Ann Arbor, MI 48108

myles.sigal@medstat.com
734-913-3466
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm.. I don't recall having issues with null data getting turned into spaces in the transformer. Usually, people just think a field is null when in fact it is not. I'm curious what 'subbu' would see in the debugger as his job ran when it processes the row with the null. Does the watch variable show the value as 'NULL' or just blank? Your field may be coming in with spaces in it, which if it does it will not test as true with IsNull(). If there is a possibility of mixing spaces and nulls in fields, I'll usually test for that and explicitly set the field to @NULL before processing it further.

-craig
msigal
Participant
Posts: 31
Joined: Tue Nov 26, 2002 3:19 pm
Location: Denver Metro

Post by msigal »

Craig - I've debugged with a file that had nulls and nulls mixed with characters and found that the debugger showed spaces where the nulls were. Additionally, I used Seq(input[byte,1]) in a separate stage variable and when I debugged the stage variable returned 32, space, 0 for null. You kindly assisted with that issue in the topic "Reappearing Nulls". - Myles
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are two issues here.
The first is, what does the original poster mean by "null". Context suggests that what is being meant is, in fact, "zero-length string", which is definitely not the same as NULL (unknown value). One tests for zero-length string with comparison operator or Compare() function, one tests for NULL with IsNull() function. It is not possible to compare anything to the @NULL system variable (though such a comparison IS possible to the @NULL.STR system variable, which contains "CAST (NULL AS CHAR(1))".
The second issue is whether true NULL is ever converted in a Transformer stage. As far as I am aware, this does not happen, though it can occur if there is a sequential file stage on the other end of a link (there is capability on the Format tab to specify how NULL is handled in sequential file stages).

As far as the original problem is concerned, if Not(IsNull(column)) is accepting the row, then column is not NULL.
It will become necessary (and the Seq() function and/or the Len() function is a good way) to find out exactly what is in the column from the input link).
Post Reply