Page 1 of 1

Null Handling

Posted: Mon May 28, 2012 9:10 pm
by aruncser
Hi,

I'm new to datastage.I'm creating my first parallel job.
In this job,I'm reading a flat file in which there is a column having null value.Now while writing this input into an csv output file I want to have BLANK mentioned in place of that null value.
In null field value I tried writing BLANK with single/double quotes but its not working.
Any help on this !!!!!

Regards,

Arun

Re: Null Handling

Posted: Mon May 28, 2012 10:08 pm
by jneasy
Have you checked to make sure that the field in question is flagged "Yes" as a nullable field in the Columns tab?

Cheers,
Joseph Neasy.

Re: Null Handling

Posted: Mon May 28, 2012 10:42 pm
by aruncser
Yeah...it's checked but still I'm not able to print BLANK.

Posted: Mon May 28, 2012 11:33 pm
by ray.wurlod
Set the Null Field Value property to BLANK for that column.

Posted: Tue May 29, 2012 12:44 am
by aruncser
I tried doing this but this is not working.I typed BLANk in null field value but its not printing BLANK in output file.

Posted: Tue May 29, 2012 12:54 am
by ray.wurlod
Then your field does not contain null. Maybe it contains "". This is not the same as null (null is "unknown value", whereas you know that "" is a zero-length string).

Re: Null Handling

Posted: Tue May 29, 2012 7:48 am
by ramsubbiah
Hi,

When you say column is having null value, what is the exact value? is that empty "" or string NULL ? as far as my concern flat file will not hold the NULL value.
Null filed value property is used to read the records and assign NULL value for that column or all columns if the specified value in the Null file value property matches the actual value of the particular source column.

Hope this clarifies.

Thanks,
Ram

Posted: Tue May 29, 2012 7:59 am
by zulfi123786
aruncser wrote:I tried doing this but this is not working.I typed BLANk in null field value but its not printing BLANK in output file.
in the NULL field value property when you have typed 'BLANK' and ran you job, if the column of a record had NULL then your CSV file will show "BLANK" (characters "BLANK" not "" ) for that column of the record. you need to view the file using texpad as you are on windows.

if you want "" in place of NULL you have to set

Code: Select all

NULL Field Value = ""
and then view the data from a text exitor like textpad

Posted: Tue May 29, 2012 8:09 am
by ramsubbiah
Hi Zulfi,

Not exactly . suppose my source field has value empty "" then if i need to populate actual NULL value these column then i need to mention Null Field value = "" . so during run time actual NULL value will be assigned.

Thanks,
Ram

Posted: Tue May 29, 2012 8:27 am
by zulfi123786
what you need to understand is "there is no NULL in a CSV (sequential file)"

A sequential file is just a collection of text characters and since a traditional NULL cant be stored in a sequential file, the sequential file state offers us "NULL field value" option where you specity what the stage has to write when it finds NULL .

If you plan to use the sequential file in another job then you need to specify the same NULL field value at the time of writing and at the time of reading in the other job

Example:
if you have a job JOB A
Oracle stage ----->Seq file stage

and say your table data is

ID NAME
10 NULL

and i chose to use '$#$#' to hold NULL (NULL Field value='$#$#') in the sequential file stage

then your file would look like

ID NAME
10 $#$#

In the following job JOB B i am reading the seq file
Seq file stage ----->Sort stage ---->Dataset

i specity the same NULL Field value='$#$#' in the seq file stage of JOB B and JOB B will replace $#$# in the file to NULL and load it in the dataset.

Posted: Tue May 29, 2012 8:36 am
by ramsubbiah
Hi,

Thanks. Even that is what my understanding also.

Thanks,
Ram