Record with Null getting dropped for Nullable col in PX 7.5.

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

Post Reply
sharathkamathm
Participant
Posts: 7
Joined: Thu Apr 26, 2007 11:33 am
Location: Bangalore

Record with Null getting dropped for Nullable col in PX 7.5.

Post by sharathkamathm »

Hi,

I have simple job with

Dataset ---> Transformer ---> Teradata Enterprise Stage

Ex: Null Record ---- 1, ABC, 0, NULL, 10

Job is completing with following warning:
"For Trg Col 'A' cannot load with Null so Record dropped."

i.e. Its loading all records except 3 records which has Null in Source col 'A' (Dataset) while loading Trg Col 'A' (Teradata) and all 3 records are getting dropped even though Trg Col 'A' is Nullable column. This is in PX with DS v7.5.2.

Note: In transformer i am doing 2 thing in stage variable
1. StgVar1 = DecimaltoString(Src col 'A', "suppresszero")
2. StgVar2 = if Len(Trim(StgVar1) = 0 then -1 else StgVar1

And after this loading StgVar2 to Trg Col 'A'

But as it was not loading to Trg, So I have tried in Transformer by
adding another stage variable with

3. StgVar3 = if isnull (StgVar2) then setnull() else stringtodecimal(StgVar2)

and then loading

Stagevariable to Trg col 'A'
(Trg col 'A' --> Decimal, len=38 and scale=10 with Nullable)....

But "StgVar3" didn't work.....So, Need help on the same.... :o
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Stage variables do not support nulls.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sharathkamathm
Participant
Posts: 7
Joined: Thu Apr 26, 2007 11:33 am
Location: Bangalore

Post by sharathkamathm »

Please let me know wht changes that i should do to job but with retaining "StgVar1" and "StgVar2"...stage variables in transformer....
Also i need this record with Null to load from Src col 'A' (dataset) to Trg col 'A' (Teradata)..... :?:
dsuser_cai
Premium Member
Premium Member
Posts: 151
Joined: Fri Feb 13, 2009 4:19 pm

Post by dsuser_cai »

If you use oracle as source, then use a NVL function to conver the null values to something else, or i think you can use NullToEmpty or NullToValue function in the transformer.
Thanks
Karthick
sharathkamathm
Participant
Posts: 7
Joined: Thu Apr 26, 2007 11:33 am
Location: Bangalore

Post by sharathkamathm »

Actually i am bring in Source with this couple of records with NULL and i need to push these record (with NULL) as it is in Target....and my soucre (Dataset) and Trg (Teradata Enterprise Stage).....

Note: In transformer i am doing 2 thing in stage variable
1. StgVar1 = DecimaltoString(Src col 'A', "suppresszero")
2. StgVar2 = if Len(Trim(StgVar1) = 0 then 1 else StringtoDecimal(StgVar1)

And after this loading stage variable "StgVar2" to Trg Col 'A'

(Trg col 'A' --> Decimal, len=38 and scale=10 with Nullable)....

but this is not working......

let me know if it is any issue with conversion i.e.
1) DecimaltoString()
2) StringtoDecimal()

or
can anyone help with any workaround to load this NULL record to Target as it is getting dropped!!!! :?:
Pagadrai
Participant
Posts: 111
Joined: Fri Dec 31, 2004 1:16 am
Location: Chennai

Post by Pagadrai »

Hi,
Can you explain why you are doing DecimalToString and StringToDecimal?
I dont think these stage variables are required.

can you elaborate what you are trying to achieve?
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

What was wrong with the guidance you have already been given?

2 clear bits of advice were already given:
1) Stage Variables cannot hold nulls
2) Use help files to read about NullToValue

Can maybe do with reading about DecimalToString and StringToDecimal too...
Pagadrai
Participant
Posts: 111
Joined: Fri Dec 31, 2004 1:16 am
Location: Chennai

Post by Pagadrai »

Hi,
is your target column Nullable in database?
please verify that by inserting NULL values using a sql statement outside Datastage.

And when you do conversion functions, you need to handle NULL values.
If your requirement is just to load the source data to target without
any transformations, then I dont understand why you need those conversion functions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Disable operator combination to get a better idea (some idea) of which stage is throwing the errors.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dsuser_cai
Premium Member
Premium Member
Posts: 151
Joined: Fri Feb 13, 2009 4:19 pm

Post by dsuser_cai »

Try to handle the null.. may be by using modify stage.. or try to get the rejected records in a text file and read from unix (from putty) the data might have some new line character, in that case try to use a chr function to suppress it.

For example, when u read the file from unix it should be like this.

'A','123','', 'hyw'

you should see only '' (two single quotes) for null value and if you see some space or a new line character then there is something else.. and we need to handle that differently.
Thanks
Karthick
Ramona Reed
Participant
Posts: 7
Joined: Thu Nov 17, 2005 7:22 am

Post by Ramona Reed »

The following may help you:

stageVar1 = If IsNull(src A) Then "" else If Trim(src A) = "" Then "" else Trim(src A)

stageVar2 = StringToDecimal(stageVar1)

Handle the null values with the first stage variable, and work with the second stage variable for your fields.
With God all things are possible.
sharathkamathm
Participant
Posts: 7
Joined: Thu Apr 26, 2007 11:33 am
Location: Bangalore

Post by sharathkamathm »

Thanks to ALL, day before yesterday, I have resolved it by using all u ppl inputs and I did following changes and it worked,

In transformer i am doing 2 thing in stage variable,

1. StgVar1 = If IsNull(Src col 'A') then "#" else DecimaltoString(Src col 'A', "suppresszero")

2. StgVar2 = If StgVar1 = "#" then "#" Else if Len(Trim(StgVar1) = 0 then 1 else StringtoDecimal(StgVar1)

And after that load StgVar2 to Trg Col 'A',

3. Trg Col 'A' = If StgVar2 = "#" then SetNull() else StgVar2

Actually, i needed to retain both stage variable and error was Src record was with Null..n stage var unable to handle null....so issue got resolved and trg was loaded with Null!!!!
Post Reply