Page 1 of 1

In Informix DataBase condtion for NULL value getting fail

Posted: Sun Apr 16, 2006 11:33 pm
by prasoon
Hi
In DS I given following condition

If (Column1= 'Y' AND Column2= 'Y' AND Column3= 'Y' AND Column4= 'Y' then 'Y' else 'N')

But when ALL the column's getting NULL value then in Target Table updating with NULL value. According to my requirement It should be either 'Y'(if Condition thru) or 'N'

Due to this problem most of the record not updating in target Table!!

Please suggest me How I can solve this problem.

Posted: Mon Apr 17, 2006 12:52 am
by ray.wurlod
Welcome aboard. :D

NULL is always a tricky concept, and therefore should be explicitly handled.

Code: Select all

If (IsNull(Column1) Or IsNull(Column2) Or IsNull(Column3) Or IsNull(Column4)) Then 'N' Else If (Column1= 'Y' AND Column2= 'Y' And Column3= 'Y' AND Column4= 'Y') then 'Y' else 'N' 
It is also the case that your expression

Code: Select all

If (Column1= 'Y' AND Column2= 'Y' AND Column3= 'Y' AND Column4= 'Y' then 'Y' else 'N') 
has the right parenthesis misplaced - it should follow "Column4='Y'". This alone may be a sufficient correction, since NULL always takes the ELSE path in an IF statement, on the grounds that it can never be asserted to be "true".

However, I always advocate handling NULL explicitly, if for no other reason than to communicate to the next developer that I've considered it.

Re: In Informix DataBase condtion for NULL value getting fai

Posted: Mon Apr 17, 2006 3:12 am
by prasoon
In Data Stage Transformation following condition given

IF Trim (gender) = 'Male' OR Trim (gender) = 'Female' OR Trim (gender) = 'Indeterminate' THEN 'Y' ELSE 'N'

Source: Table 1
Column Nullable
Gender No

Target: Table 2
Column Nullable
Sex Yes

Please let me know how some of the row of Table 2 getting null values.



prasoon wrote:Hi
In DS I given following condition

If (Column1= 'Y' AND Column2= 'Y' AND Column3= 'Y' AND Column4= 'Y' then 'Y' else 'N')

But when ALL the column's getting NULL value then in Target Table updating with NULL value. According to my requirement It should be either 'Y'(if Condition thru) or 'N'

Due to this problem most of the record not updating in target Table!!

Please suggest me How I can solve this problem.

Posted: Mon Apr 17, 2006 12:20 pm
by diamondabhi
U need to handle nulls and sometimes u need to even check for spaces,
ex: len(trim(linkname," ","A"))=0

Posted: Mon Apr 17, 2006 3:08 pm
by ray.wurlod
Where is the source coming from? Just because you declare a column to be not null in your DataStage job does not enforce non-nullability. For example, if your source is a text file, the Format tab on the Sequential File stage specifies what will be interpreted to be null (by default it is "") and this is irrespective of the nullability setting for that column. You can override the definition of null representation for particular columns in the Columns grid. Scroll to the right to find it. Replace the empty string with something else, such as "<NULL>".

Post number 11111

Posted: Tue Apr 18, 2006 2:42 am
by prasoon
Source is also INFORMIX
ray.wurlod wrote:Where is the source coming from? Just because you declare a column to be not null in your DataStage job does not enforce non-nullability. For example, if your source is a text file, the Format tab o ...

Posted: Tue Apr 18, 2006 6:53 am
by gateleys
ray.wurlod wrote:Post number 11111
Great going Ray. The numbers come with a wealth of information for all of us here in the forum. Thanks.

gateleys

Posted: Tue Apr 18, 2006 7:04 am
by sb_akarmarkar
I suggest check from empty after triming

Trim(Column)=''


--Anupam

Posted: Tue Apr 18, 2006 8:26 am
by kumar_s
What is the target column datatype?
What if some of the input fields comes as expetec (is it getting populated with either 'Y' or 'N')?
What if you try

Code: Select all

IF (Trim(gender) = "Male" OR Trim(gender) = "Female" OR Trim(gender) = "Indeterminate") THEN 'Y' ELSE 'N' 

Posted: Mon May 08, 2006 5:23 am
by prasoon
1.Target column datatype is CHAR
2.other column are populatting according to condition.
3.I'm using following condition
IF (Trim(gender) = "Male" OR Trim(gender) = "Female" OR Trim(gender) = "Indeterminate") THEN 'Y' ELSE 'N'
kumar_s wrote:What is the target column datatype?
What if some of the input fields comes as expetec (is it getting populated with either 'Y' or 'N')?
What if you try

Code: Select all

IF (Trim(gender) = "Male" OR Trim(gender) = "Female" OR Trim(gender) = "Indeterminate") THEN 'Y' ELSE 'N' 

Posted: Mon May 08, 2006 5:47 am
by kumar_s
Ooff... a quick response...
Are you sure you are lookin after the output directly after the transformation and not after any join or merge where the null will play a vital role.
Try using debugger to know rows wise processing.

Posted: Mon May 08, 2006 6:14 am
by prasoon
Sorry Kumar for late response....
Ok Now I got the reason why data is not updating those record.
In that job near about 12 Transformation using I was concentrated only on derivation given on Transformation.

But Problem is from source table only data is not fetching for those 268 record among 23458690 record.
I have to look on that only!!


Thanks a lot for support kumar!!
:)
kumar_s wrote:Ooff... a quick response...
Are you sure you are lookin after the output directly after the transformation and not after any join or merge where the null will play a vital role.
Try using debugger to know rows wise processing.

Posted: Mon May 08, 2006 6:28 am
by kumar_s
Perhaps to Dsxchange :D