Error when removing Leading zeros from a numeric data

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
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Error when removing Leading zeros from a numeric data

Post 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
Mac4rfree
singhald
Participant
Posts: 180
Joined: Tue Aug 23, 2005 2:50 am
Location: Bangalore
Contact:

Post by singhald »

you can also used LTrim function
Regards,
Deepak Singhal
Everything is okay in the end. If it's not okay, then it's not the end.
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post 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')
Cheers
Ravi K
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Yep...
Cheers
Ravi K
Post Reply