how to transfer nulls as nulls?

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

mctny
Charter Member
Charter Member
Posts: 166
Joined: Thu Feb 02, 2006 6:55 am

how to transfer nulls as nulls?

Post by mctny »

I have a simple but big problem :) I have a sequential file as input a transformer and oracle enterprise stage as target. I am using delimited flat file and some fields are nullable, and I want to transfer those fields as null if it is null. I read one col as varchar length 7 this column is number(7,4) in oracle. when I load the target table I see that the nulls at the input are transferred as zero, I couldnot make it null no matter what I tried. any ideas?
Thanks,
Chad
__________________________________________________________________
"There are three kinds of people in this world; Ones who know how to count and the others who don't know how to count !"
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

Strange. I dont think that datastage is the culprit. Check if default display for nulls in oracle is zero. (i assume you are running a query in oracle to check)

Otherwise Try and force null into the field.

If isnull(XYZ) then NULL() else XYZ
mctny
Charter Member
Charter Member
Posts: 166
Joined: Thu Feb 02, 2006 6:55 am

Post by mctny »

Krazykoolrohit wrote:Strange. I dont think that datastage is the culprit. Check if default display for nulls in oracle is zero. (i assume you are running a query in oracle to check)

Otherwise Try and force null into the field.

If isnull(XYZ) then NULL() else XYZ
I use toad to check the table. ans also I tried if IsNull(X) then SetNull() else X
but it didnot help either
Thanks,
Chad
__________________________________________________________________
"There are three kinds of people in this world; Ones who know how to count and the others who don't know how to count !"
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Re: how to transfer nulls as nulls?

Post by kris007 »

mctny wrote: when I load the target table I see that the nulls at the input are transferred as zero, I couldnot make it null no matter what I tried. any ideas?
Are you sure you are looking at the same record in source and target?
You get 0's when you move from varchar to NUmber field if it has any non-numeric data.Make sure you are handling null values correctly in the seq file stage.
Kris

Where's the "Any" key?-Homer Simpson
mctny
Charter Member
Charter Member
Posts: 166
Joined: Thu Feb 02, 2006 6:55 am

Re: how to transfer nulls as nulls?

Post by mctny »

kris007 wrote:
mctny wrote: when I load the target table I see that the nulls at the input are transferred as zero, I couldnot make it null no matter what I tried. any ideas?
Are you sure you are looking at the same record in source and target?
You get 0's when you move from varchar to NUmber field if it has any non-numeric data.Make sure you are handling null values correctly in the seq file stage.
thank you for the response, yes I am sure I am looking at the right records. I solved the problem by using unknown field type at the right side of transformer
, when I read the seq file it is still varchar
Thanks,
Chad
__________________________________________________________________
"There are three kinds of people in this world; Ones who know how to count and the others who don't know how to count !"
madhukar
Participant
Posts: 86
Joined: Fri May 20, 2005 4:05 pm

Re: how to transfer nulls as nulls?

Post by madhukar »

Check the nullable property in input & output of transformer.
if u r not doing any explicit tranformation of converting varachar to number(7,4) in transformer then, it does implicit conversion.

if ur varchar column does not have proper number, it will put zero as default.

try an explicit conversion in transformer.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Historical Geographical Note
UR is (was) an ancient Babylonian city. There is no such English word.

:evil:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
madhukar
Participant
Posts: 86
Joined: Fri May 20, 2005 4:05 pm

Post by madhukar »

ray,

I regret the inconvenience caused.

correction:

please read "u r" as you are and "ur" your
puli.reddy
Participant
Posts: 28
Joined: Wed Jan 11, 2006 8:29 pm
Location: Singapore
Contact:

Post by puli.reddy »

Hi All

I had the same problem, I used @NULL function to hardcode the values as null. It doesn't work when we are populting into Oracle. Try the below
If IsNull(Arg1) = 1 Then '' Else Arg1. It may work out. I had this problem when I was populating into Oracle8i database
Thnaks and Regards,
AnjiReddy.
prabu
Participant
Posts: 146
Joined: Fri Oct 22, 2004 9:12 am

Post by prabu »

Hello folks,
the following is the hint for the null value property of sequential file.

Code: Select all

On import, the [b]value NOT expression NOT system variable [/b] given to a field containing a null. On export, the value given to an exported field if the source field is set to null.
May be a number, string, or C-style literal escape character, such as \123 or \xAB, if you want to use a non-printable byte value.
unfortunately, @NULL or @NULL.STR , which are "system variables" are not considered for the above said propety.


1)question is, if i have Oracle Enterprise stage mapped directly to a seq file, how to handle the nulls as NULLS.

i can understand if it is

Stage -> Transformer -> Seq file

i can use null handling function like SetNull.

any volunteers :wink:
prabu
Participant
Posts: 146
Joined: Fri Oct 22, 2004 9:12 am

any volunteers to exlain @NULL and null value expression

Post by prabu »

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

Post by kumar_s »

Prabu - What if you dont use any of these properties. Null should be transfered as Null. Are you getting the same issue as Cetin getting?

Cetin - Try to load in to sequential file and check if you are getting 0s.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
mctny
Charter Member
Charter Member
Posts: 166
Joined: Thu Feb 02, 2006 6:55 am

Post by mctny »

Hi Kumar,
I agree with you. Nulls should be tansferred as nulls if you don't do anything.

I solved the problem using unknown data type in the right side of the mapping of the transformer. I have to use transformer anyway, because of other fields ransformation.
as far as I remember, when I view the data at the source stage( which is sequential) I can view nulls as nulls. I remember dumping the data to sequntial file to test, and it was also fine.

I think in my case it was the transformer that cause the problem ( i.e. automatically converting nulls to zero due to the field type)
Thanks,
Chad
__________________________________________________________________
"There are three kinds of people in this world; Ones who know how to count and the others who don't know how to count !"
prabu
Participant
Posts: 146
Joined: Fri Oct 22, 2004 9:12 am

Post by prabu »

mctny wrote:Hi Kumar,
I agree with you. Nulls should be tansferred as nulls if you don't do anything.

I solved the problem using unknown data type in the right side of the mapping of the transformer. I have to use transformer anyway, because of other fields ransformation.
Cetin, my question is,if its a straight mapping between the source(oracle table) and target(sequential file) how would i handle it. To restate,
unfortunately, @NULL or @NULL.STR , which are "system variables" are not considered for the above said propetyThe problem is null value property is not taking @NULL as a value.
i think the problem is, it is treating @NULL as literal instead of as a system variable.

My question is:-
1)
if there is NO transformation inloved, is there no way to write nulls as null itself into a sequemtial file.
2) how can i use system variables as property value [as discussed for null value - @NULL]. is it allowed?

looking for some clues??

regards,
Prabu
prabu
Participant
Posts: 146
Joined: Fri Oct 22, 2004 9:12 am

Post by prabu »

kumar_s wrote:Prabu - What if you dont use any of these properties. Null should be transfered as Null. Are you getting the same issue as Cetin getting?
it's not allowing me to load the seq file, if the field value is null and the null value property is not set. Meaning, these null records are rejected.
i assume null value is a prerequisite provided the input field may contain nulls.

the mock log messages for your reference.

Code: Select all

"COL" is null but no null export handling is defined
Export unsuccessful at record n
Post Reply