Remove leading zero before decimal point

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
jarretj1
Participant
Posts: 2
Joined: Mon Jul 29, 2013 11:57 pm

Remove leading zero before decimal point

Post by jarretj1 »

I am having an issue after splitting a query into 2 ODBC stages that the result is now displaying -0.01 instead of -.01.

The same for 0.1 insead of .1

How can I remove the leading zero in front of the negative value as the TRIM is not working ???
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. The first question is "why?" The values are identical.

You can probably apply the Fmt() function to achieve what you require - read about this function in on-line Help or in the DataStage BASIC manual.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Remove leading zero before decimal point

Post by SURA »

Consider the data type.
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Remove leading zero before decimal point

Post by ray.wurlod »

SURA wrote:Consider the data type.
There are no genuine data types in server jobs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
MrBlack
Participant
Posts: 125
Joined: Wed Aug 08, 2012 8:57 am

Post by MrBlack »

I would think all you would have to do is specific the data type as a Decimal and that would take care of your problem.

Other than that you'd have to do some fancy substringing to determine if there is only one character to the left of the decimal and if that character is a zero and if so then substring.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What happens if you add 0 to the value? As a general rule DataStage BASIC returns the shortest possible string as the result of an arithmetic operation.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jarretj1
Participant
Posts: 2
Joined: Mon Jul 29, 2013 11:57 pm

Post by jarretj1 »

adding a zero did not work, Substringing technique of course is succesfull, and about to try the FMT command.

Thanks for the help
Post Reply