How to avoid NULL to reject - in SWITCH case

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

kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

How to avoid NULL to reject - in SWITCH case

Post by kumar_s »

Hi all,
In input stage i have a column STATUS which cant have Y or N or null. I used switch to seperate to two pipeline. null should go to N link. Bul i can handle null value to flow to a stream, it goes to Reject link. I tried with '' , "", @NUL, @NULL.STR , NULL but doesent work. But i can make it up with transformer stage with "". STATUS is Varchar with 1 byte length. Can any one help me out.
Thanx in advance
-kumar
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

Before passing the selector column to 'Switch' stage, use modify stage to assign 'N' if the field has null value then use case stmt in switch. Then these input rows can be pipelined to two stream.

HTWH.

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

Post by ray.wurlod »

@NULL and @NULL.STR are DataStage BASIC system variables and therefore inappropriate in parallel jobs.
What kind of "input stage" are you using? For example, the Reject link from a Sequential File stage only handles rows that do not match the schema associated with the input link.
You need to follow up with some method of handing the null, perhaps a Modify stage to convert same to 'N', and only then direct rows according to the value in STATUS, perhaps with a Switch stage. Or do both operations in a Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Input stage is simply a sequential stage. It is always works fine using transformer stage, but i thought in this scenario switch stage might work better :roll:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It may, but you have to handle null explicitly and have the target column nullable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
alisoviejo
Participant
Posts: 49
Joined: Fri Nov 11, 2005 10:19 am

Post by alisoviejo »

Hi,

If we cannot use @Null, how do we pass a null into a float field?. I have tried to sue SetNull() and doesnt work.
ALISO
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Post by benny.lbs »

Why not have a try on Filter stage ?

filter
-where 'STATUS = "Y" or STATUS = "N"'
-where 'STATUS is null'
alisoviejo
Participant
Posts: 49
Joined: Fri Nov 11, 2005 10:19 am

Post by alisoviejo »

I need to pass a Null value intoa float field, the solution you have mentioned is to detect Null values I believe.
ALISO
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi,
If Null is passed to Float field 0s will be defaulted. SetNull() can be used for the same reason.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

SetNull() can be used provided the target column is defined as nullable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

ray.wurlod wrote:SetNull() can be used provided the target column is defined as nullable.
But even nullable float column when passed with SetNull() will hold 0s :?
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
alisoviejo
Participant
Posts: 49
Joined: Fri Nov 11, 2005 10:19 am

Post by alisoviejo »

Thats what is happening on my end , I used SetNull() still it turns up to be 0!
ALISO
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Have you reported this apparent bug through your support provider?

Is any of you who are experiencing this symptom running parallel jobs on a Windows platform? I note that the OP is on UNIX. If on UNIX, can you please post what kind of UNIX (for example AIX, HP-UX, Solaris, etc.)?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

UNIX - AIX.
But i was under the impression that, Decimal is also similar to integer which doesnt hold NULL rather 0s in it. :?
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

ANY data type can hold null, provided that the column is defined as nullable (that is, not defined as NOT NULL).

Null (unknown value) is not the same as "" (empty string, or zero-length string, which is a known value). You can not put "" into any kind of numeric column.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply