Unable to convert the Varchar(9) to Numeric(9)

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
kshah9
Participant
Posts: 7
Joined: Wed Oct 06, 2010 11:32 am
Location: Pune

Unable to convert the Varchar(9) to Numeric(9)

Post by kshah9 »

I want to convert my Varchar(9) field to Numeric(9), but I am not able to do that in TFM stage with StringToDecimal Function. So plz help me in this...
Regards,
Kunal Shah
kkalyanrao@gmail.com
Participant
Posts: 11
Joined: Thu Feb 10, 2011 1:09 am
Location: Kuala Lumpur

Post by kkalyanrao@gmail.com »

Try this - StringToDecimal(InputColumn) and set output column data type to numeric(9)
- Kalyan
kshah9
Participant
Posts: 7
Joined: Wed Oct 06, 2010 11:32 am
Location: Pune

Post by kshah9 »

Thanks Kalyan, I did that, but still not able to get the desired result, and getting the Zeros in output. but the same functionality is working fine for other job. So appreciate the help in this matter...
Best Regards,
Kunal Shah
priyadharsini
Participant
Posts: 40
Joined: Mon May 11, 2009 12:19 am
Location: Madurai

Post by priyadharsini »

Check the director for any warnings.
kshah9
Participant
Posts: 7
Joined: Wed Oct 06, 2010 11:32 am
Location: Pune

Post by kshah9 »

Guys, Thanks for Help, the issue is resolved, it was the problem due to ^M character in Source File.

Thank you all for your help.
Best Regards,
Kunal Shah
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

Post by myukassign »

Alrt ...so here is the issue...

e.g. you are having a varchar '777777777' and you are converting and copying to decimal 9 using stringTodecimal and might have declared the legnth of your decimal field as 9 and scale 2.

now the string function will convert your function to 777777777.00

so see the total length of the converted value, it's 11.

Will it fit? it wont fit.... so datastage will show you 00000000 with a warning...


so now you know what to do... change the length and scale of target decimal field, it will work for sure.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

They've already posted the issue and the fact that it was resolved, so unsure why you are bringing scale into the picture, it doesn't really seem relevant here.
-craig

"You can never have too many knives" -- Logan Nine Fingers
myukassign
Premium Member
Premium Member
Posts: 238
Joined: Fri Jul 25, 2008 8:55 am

Post by myukassign »

chulett wrote:They've already posted the issue and the fact that it was resolved, so unsure why you are bringing scale into the picture, it doesn't really seem relevant here.
hmm..

Actully while I was replying and posting the reply the issue got solved...:)

well.. I faced a similar issue and all 000000 was because of the length and scale... so the intention was to help...
Post Reply