Page 1 of 2

Converting string to number

Posted: Mon Mar 15, 2010 9:38 am
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.

Posted: Mon Mar 15, 2010 10:06 am
by chulett
Make an explicit conversion using the StringToDecimal() function.

Posted: Mon Mar 15, 2010 11:35 am
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.

Posted: Mon Mar 15, 2010 11:54 am
by chulett
So, do we have to guess what the "abort" is?

Posted: Mon Mar 15, 2010 11:56 am
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")')

Posted: Mon Mar 15, 2010 2:32 pm
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.

Posted: Mon Mar 15, 2010 3:24 pm
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?)

Posted: Mon Mar 15, 2010 3:34 pm
by chulett
Was hoping for a little 'self discovery' along the way from gentle nudges in the proper direction. :wink:

Posted: Mon Mar 15, 2010 3:55 pm
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

Posted: Tue Mar 16, 2010 7:45 am
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

Posted: Tue Mar 16, 2010 7:52 am
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.

Posted: Tue Mar 16, 2010 8:34 am
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 ?

Posted: Tue Mar 16, 2010 8:51 am
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

Posted: Tue Mar 16, 2010 9:25 am
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.

Posted: Tue Mar 16, 2010 9:37 am
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.