zero output as 0.00

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
gmt_etldev
Premium Member
Premium Member
Posts: 7
Joined: Mon Dec 17, 2007 1:37 am
Location: Boston, MA

zero output as 0.00

Post by gmt_etldev »

Hello,
I am having a problem with the display of zero as 0, yet I want it to display as 0.00. I have tried the results of other postings, with no success. I have switched datatypes, suppressed zeroes, converted to a double or float, if-then-else, etc. - but it is still not working.

In the transformer stage:
Input: Decimal 38,2
Stage Variable: Decimal 38,2 used to calculate an amount
Output: Varchar 40 with a
DecimalToString(STAGE_VARIABLE_NAME_HERE,"suppress_zero") conversion.

I still get 0 where I need 0.00

Any ideas?

Thanks,
Barbara
horserider
Participant
Posts: 71
Joined: Mon Jul 09, 2007 1:12 pm

Post by horserider »

What's ur target?
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Hello Barbara,

Are you trying to display in the target as '0.00' (varchar datatype)?
If yes did you try this:

Code: Select all

Field(DecimalToString(STAGE_VARIABLE_NAME_HERE, 'fix_zero, suppress_zero'), '.', 1) 
          : '.' : Left(Field(DecimalToString(STAGE_VARIABLE_NAME_HERE, 'fix_zero'), '.', 2) : Str('0', 2) , 2) 
Let us know your results. :)
Thanks and Regards!!
dspxlearn
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Hello Barbara,

Are you trying to display in the target as '0.00' (varchar datatype)?
If yes did you try this:

Code: Select all

Field(DecimalToString(STAGE_VARIABLE_NAME_HERE, 'fix_zero, suppress_zero'), '.', 1) 
          : '.' : Left(Field(DecimalToString(STAGE_VARIABLE_NAME_HERE, 'fix_zero'), '.', 2) : Str('0', 2) , 2) 
Let us know your results. :)
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 »

Numeric data are stored in binary format, you can not affect their display. You need to convert to string to have any control over the display format.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
gmt_etldev
Premium Member
Premium Member
Posts: 7
Joined: Mon Dec 17, 2007 1:37 am
Location: Boston, MA

Post by gmt_etldev »

Thank you very much - that code worked! My target is a sequential file.
I really appreciate your help!
Thanks,
Barbara
Post Reply