Page 1 of 1

Error when removing Leading zeros from a numeric data

Posted: Fri Jul 08, 2011 1:40 am
by mac4rfree85
Hi Guys,

I am trying to remove leading zeros from a numeric data which is coming in a Varchar field.

Source data : 000275
Target Data : 275

Both the Source field and target field are Varchar Field. This is what i am doing.

Code: Select all

DecimalTostring(StringToDecimal(InCol), "suppress_zero")
I am getting the following error in Director

Code: Select all

Conversion error calling conversion routine decimal_from_string data may have been lost
Can somebody point out what i am doing wrong.

Cheers

Posted: Fri Jul 08, 2011 2:15 am
by singhald
you can also used LTrim function

Posted: Fri Jul 08, 2011 7:04 am
by Ravi.K
DecimalToString function could be used for decimal attributes. But whereas you are reading it as Varchar and it leads to error. Use the below derivation.

Trim (Inputcol,'0' ,'L')

Posted: Fri Jul 08, 2011 7:13 am
by chulett
So I guess you missed the inner StringToDecimal function?

Regardless, as noted one can simply trim them off rather than going through that double-conversion.

Posted: Fri Jul 08, 2011 7:34 am
by Ravi.K
Yep...