Is there a better way to handle nulls ???

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
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Is there a better way to handle nulls ???

Post by cosec »

Loading data from a fixed with Sequential File to a DB2 Table. Some of the records I load consists of null columns...they are of data type date, timestamp,char,integer,decimal

for date and timestamp I use a validation for the null handling....

For the others data types if I dont validate I get warnings.....

Is it necessary for me to validate the columns with other data types for nulls...isn't there a simpler way to perform this....?


Thanks
srimitta
Premium Member
Premium Member
Posts: 187
Joined: Sun Apr 04, 2004 7:50 pm

Post by srimitta »

Simple and better way is handle Null's coming from source column's explicitly:
1). When Tagret column is defined as Not Null irresptive of data types.
2). When Target column is defined as Numeric, Integer, Decimal, Small Int, Float..........other data types which are defined to accept only Numeric values even if the column is set accept Null values.

:lol:
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If it is a fixed width file, you need to check for each and every one. As there are no nulls in a fixed width file. They are all character fields.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Is there a better way to handle nulls ???

Post by gateleys »

cosec wrote: Is it necessary for me to validate the columns with other data types for nulls...isn't there a simpler way to perform this....?
Yeah it is necessary if your target requires that column to be not null.

And, what's so complex about handling nulls? :?

gateleys[/b]
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Note, too, that the representation of NULL in the Columns grid must have the same number of characters as the width of the field to which it relates.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kommven
Charter Member
Charter Member
Posts: 125
Joined: Mon Jul 12, 2004 12:37 pm

Post by kommven »

A typical scenario with Fixed width flat file will always represent NULL as spaces equal to the field length.

DataStage will never consider space as a valid representation for NULL.

I will do a Length after a Trim Validation to find out if its a NULL representation for a field or not.

Code: Select all

If Len(Trim(InputLink.InputColumn)) = 0 Then SetNull() Else InputLink.InputColumn
But using this feature should be considered conciously and assumed as a data representation with spaces will be lost during this transformation.

Another approach is if all the available characters in that data are spaces then thats a NULL {Can be achieved by writing a Routine maybe} -- :idea:

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

Post by ray.wurlod »

Can be achieved in the metadata.

That's the point I've been making.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Thanks for all your responses....I guess I have no choice but to handle all the columns for nulls.....I was looking for a simpler solution as I have an enormous number of jobs to alter....thanks again...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well... yes, you have to determine which fields need to have null handling. Note that that is a blanket statement regardless of source or situation - one of your jobs as a developer is to determine if nulls will wreak havoc on your process and handle them properly. Always.

While we'd all love to have a 'simpler solution' handed to us for everything, that's not always possible. Besides, this isn't exactly a complicated solution that you need in this case - what sucks for you is the fact that it wasn't done originally and now you have to retrofit this into an 'enormous number' of jobs. Look on the bright side - it's a great object lesson. :wink: Involve others. Share the pain!

And in this particular case, Ray has given you about the simplest solution of all - but I get the impression you keep overlooking it. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Could you identify the rotten apples in a barrel without inspecting every one?
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