Page 1 of 1

Remove leading zero before decimal point

Posted: Tue Jul 30, 2013 12:10 am
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 ???

Posted: Tue Jul 30, 2013 12:14 am
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.

Re: Remove leading zero before decimal point

Posted: Tue Jul 30, 2013 12:15 am
by SURA
Consider the data type.

Re: Remove leading zero before decimal point

Posted: Tue Jul 30, 2013 4:33 am
by ray.wurlod
SURA wrote:Consider the data type.
There are no genuine data types in server jobs.

Posted: Tue Jul 30, 2013 9:40 am
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.

Posted: Tue Jul 30, 2013 4:29 pm
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.

Posted: Tue Jul 30, 2013 5:04 pm
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