Converting string to number

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

sreddy
Participant
Posts: 144
Joined: Sun Oct 21, 2007 9:13 am

Converting string to number

Post by sreddy »

Hi

My source is Char and lookup data is Integer.

I am getting below warning while i am runnig. Every thing is fine.

Lkp_VEN,0: When binding input interface field "LAWSON_VEND_NUM" to field "LAWSON_VEND_NUM": Implicit conversion from source type "string[9]" to result type "int32": Converting string to number.

Please help with related convertion code.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Make an explicit conversion using the StringToDecimal() function.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sreddy
Participant
Posts: 144
Joined: Sun Oct 21, 2007 9:13 am

Post by sreddy »

Thank you Hulett

Can you check this convertion.

StringToDecimal(In_VEN_Ven.LAWSON_VEND_NUM,'Trim(In_VEN_Ven.LAWSON_VEND_NUM, "0", "F")')

When i used this job is aborting.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So, do we have to guess what the "abort" is?
-craig

"You can never have too many knives" -- Logan Nine Fingers
sreddy
Participant
Posts: 144
Joined: Sun Oct 21, 2007 9:13 am

Post by sreddy »

Job status is Abort.

Can you please check below conversion.

StringToDecimal(In_VEN_Ven.LAWSON_VEND_NUM,'Trim(In_VEN_Ven.LAWSON_VEND_NUM, "0", "F")')
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

sreddy wrote:Job status is Abort.
:roll: Understand that. Please tell us why it aborted, post the fatal error message(s) from the log.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

sreddy wrote:Job status is Abort.

Can you please check below conversion.

StringToDecimal(In_VEN_Ven.LAWSON_VEND_NUM,'Trim(In_VEN_Ven.LAWSON_VEND_NUM, "0", "F")')
Putting the trim function in quotes certainly won't help. Trimming leading zeros is pretty pointless to a decimal, I would be more concerned with non-numeric characters (and spaces?)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Was hoping for a little 'self discovery' along the way from gentle nudges in the proper direction. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

chulett wrote:Was hoping for a little 'self discovery' along the way from gentle nudges in the proper direction. :wink:
Apologies for cutting your grass... hopefully he did a bit of self discovery in between
sreddy
Participant
Posts: 144
Joined: Sun Oct 21, 2007 9:13 am

Post by sreddy »

Thank you both of you

My source data is in Char data type just like below format ( 9 characters)
000000001
000000012
000000120
that is why i used Trim the Zeros.

But my lookup data is integer data type
87654
98653
34765

Help me with related function script StringtoDecimal()

Thanks
SReddy
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Help us help you. Show us the latest version of your function syntax and post the dang fatal error message(s) from the log.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Just a simple stringToDecimal(yourSourceColumn) must do the trick.

Did you ensure that all downstream column declaration (esp lookup stage) refers to that column as integer ?
sreddy
Participant
Posts: 144
Joined: Sun Oct 21, 2007 9:13 am

Post by sreddy »

Can you please send me your version of conversion script.

StringtoDecimal()

source is char 000000001

first Trim the zeros from source data with that result we have to convert the data according to lookup data type integer.

i am waiting for your reply.

Thanks
SReddy
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's no "conversion script" and no need to trim the dang zeroes. Simply call the function with your source column and populate an Integer field with the results. I am waiting for your reply.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sreddy
Participant
Posts: 144
Joined: Sun Oct 21, 2007 9:13 am

Post by sreddy »

Thank you Hulett

Below is the warning.

Still job is running.

Lkp_VEN: When checking operator: On output data set 0: When binding output schema variable "outputData": When binding output interface field "LAWSON_VEND_NUM" to field "LAWSON_VEND_NUM": Implicit conversion from source type "int32" to result type "string[9]": Converting number to string.
Post Reply