Null handling in PX Sequential files

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

vjreddy65
Participant
Posts: 7
Joined: Tue Apr 06, 2004 7:34 pm

Null handling in PX Sequential files

Post by vjreddy65 »

How do I read a Delimited sequiential file (having Null values in a couple fields ) with out dropping any of the records in PX.

Sample input file format

12|32|43
32||23

Here FIeld2/Row2 is a null. When std PX Sequential file stg is used to read this, second record is getting dropped.

Any ideas are appreciated..
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Hi

In the Sequential File Properties go to the format tab and Fill in the Null Field Value with empty string or with some default value. Also make sure that Nullable columns are handled properly in your transformation

Thanks
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
Eric
Participant
Posts: 254
Joined: Mon Sep 29, 2003 4:35 am

Post by Eric »

Remember there is no such thing as a NULL in a sequential file only an empty string ;)
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Eric - there can actually be NULLs in a sequential file; the SQL null is CHAR(128) and that can be found in strings. But you are right that the concept of NULL as it is used in databases doesn't exist in flat files.
vjreddy65
Participant
Posts: 7
Joined: Tue Apr 06, 2004 7:34 pm

Post by vjreddy65 »

Guys,
Thx for your ideas.

I have a Nothing fields like two delimiters coming side by side with nothing between them
12|32|43
32||23

Second row in the example has the scenario Iam talking about.

When I read such a row using PX sequential file, it gets dropped in reading itself. It doesn't come even till next stage. So How do I read this row without dropping it.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Just follow the suggestions that Rasi gave and you should be OK
vjreddy65
Participant
Posts: 7
Joined: Tue Apr 06, 2004 7:34 pm

Post by vjreddy65 »

As Rasi/Siva said, I even included the Null field value to diff characters but in vain. Any thoughts... :idea:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Siva's advice relates to server jobs. The way you handle zero-length strings in parallel jobs is different; but the representation of null property in the Sequential File stage is one of them. Once you can get "" into your job, you then have to monitor it right through the job design and either convert it back to a null, or supply a replacement default value, if either of those actions is appropriate.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vjreddy65
Participant
Posts: 7
Joined: Tue Apr 06, 2004 7:34 pm

Post by vjreddy65 »

Ray,
But how do I get it in to the job. Those records with NULL values are getting dropped in the sequential file stage itself and Iam not able to get it to the next stage. Suggest me a way to get them in.
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

Agree with Siva's suggesstion. We implemented the same method to handle null value, which is specify the default value in the null string column when you read the seq file and transform back to NULL in the transformer stage before writing the record into a dataset.

This would resolve the issue.

Regards
Saravanan
dsdesigner
Participant
Posts: 34
Joined: Thu Jul 29, 2004 1:03 pm

Post by dsdesigner »

Hi Vj

I may be reiterating what siva has already said, but this is what you can try for the example data that you posted that you need to read.
Go to the properties tab of the sequential file and add the property default null field value and put in ''(two single quotes) as the value.

HTH

Thanks
dsxdev
Participant
Posts: 92
Joined: Mon Sep 20, 2004 8:37 am

Post by dsxdev »

Hi VJ,
Above suggestions hold good if you have used the Null field property while writing to the file.

Otherwise you will not be able to read this record.
Actually Nulls do exist in Sequential files but these values are not interpreted correctly. To avoid any such prcarious situation, use Null field value property while writing to the file.

Then use same Null Filed value property to read the file. This will ensure that null vallues are interpretted correctly in DataStage jobs.
Happy DataStaging
lshort
Premium Member
Premium Member
Posts: 139
Joined: Tue Oct 29, 2002 11:40 am
Location: Toronto

Post by lshort »

I just completed a PX seminar. I had this same problem in an exercise. If your reading a row like:

a,,b,c,d

this row will be dropped because of the null in F2.

To solve this problem you must set the Null String property. You must pad this property with characters matching the length defined for the field that is null.

ie. if F2 is defined as char(3) you must set the Null String property to '___ ' or 000 etc.

btw: if your source file was fixed length there is an enviornment variable for Null handling which would accomplish the same thing (FIXED ONLY)

This approach worked for me.
Good Luck :-)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Clarification: That environment variable has the name APT_IMPEXP_ALLOW_ZERO_LENGTH_FIXED_NULL (whew!) and applies only to the Import and Export operators in the framework.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

But what would qualify as a 'null' in a fixed width sequential file? Any inner column that might qualify would have to be all spaces to maintain the sizing of the record. Are we talking about that or trailing (i.e. missing) columns from the end of the record? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply