DecimalToSting()

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
vrishabhsagar
Participant
Posts: 33
Joined: Mon Nov 12, 2007 1:02 am
Location: Bangalore

DecimalToSting()

Post by vrishabhsagar »

Hi All,

I have a source file col that has decimal data in form 020, but when I convert it into varchar format using DecimalToString(colname), then it is automatically converted to something like 20. I would like output in form 020 (varchar data).

Can anyone pls help.

Thanks in anticipation.

Rishabh
Rishabh Sagar V
Bangalore
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Did you try using 'Fix_xero" with the DecimalToString function?
If not please check this.

Else you can do the formatting stuff:

Code: Select all

Right( Str('0',n) : DecimalToString(InCol,"fix_zero"), n)
Please let us know your results
Thanks and Regards!!
dspxlearn
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Re: DecimalToSting()

Post by ArndW »

vrishabhsagar wrote:...I have a source file col that has decimal data in form 020...
Decimal data is not stored with leading zeroes; that is a function of how you display it. The string formatting function that
dspxlearn suggested should work for you when reconverting the number back to a string.
vrishabhsagar
Participant
Posts: 33
Joined: Mon Nov 12, 2007 1:02 am
Location: Bangalore

Have used this

Post by vrishabhsagar »

Hi All,

Thanks for responding... Right now I have used this to fix the problem,

Str("0",3-len(trim(DecimalToString(DSLink3.FLQ66B080_TOACDE1,"suppress_zero")))):DecimalToString(DSLink3.FLQ66B080_TOACDE1,"suppress_zero")

Since I am running out of time, I am unable to test ur solution. But when I test it, if I find any thing of interest I shall definetly bump this thread or PM.

Thanks Again.
Rishabh Sagar V
Bangalore
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

vrishabhsagar,
You don't need to test the code which i have posted previously. Cause, it will do the same thing as yours.Only difference, is that you are taking the exact length of the prefixed Zeros.
If your issue is solved please mark it as 'Resolved'.
Thanks and Regards!!
dspxlearn
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The answer is NO.
A Decimal number is a binary data type. Whether it has leading zeroes or not it is stored the same way. DecimalToString() generates the shortest possible valid string.
If you want to add leading zeroes, then you must do so explicitly. For example:

Code: Select all

Right("000" : DecimalToString(InLink.TheDecimal), 3)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply