Elegant decimal data conversion?

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
Richard615
Participant
Posts: 12
Joined: Tue Mar 27, 2007 11:08 am

Elegant decimal data conversion?

Post by Richard615 »

Greetings.

I've searched the forums for most of the day and looked around, and didn't see this addressed. So I thought I'd bite the bullet and post this question. As a bit of back story, I've been using older versions of DS for a good number of years, and only recently came on board to a company that's using parallel extender. So I'm still getting used to how variable data types are more important in PE than in older versions.

So.

I have a decimal field coming in on a link, and I want to write it to a delimited flat file. If I do so as a decimal, I get [space]123.. That is, I get the space for the sign, and the trailing decimal even if there is no mantissa.

I don't want this. I want no leading spaces (or zeros) and I want the decimal suppressed if not needed. If I drop this into a VarChar, that doesn't help. Nor does the DecimaltoString function. In the old world of server jobs, I would probably use something like oconv to make this happen.

Is there a simple, elegant way to do this in a PE transform that I'm overlooking? I searched the help files for various numeric and string functions, but didn't find anything applicable.

Yes, I know I can drop it into a VarChar and then strip off the unwanted parts with embedded TRIM statements. But I would think there's a simpler method that I'm missing. Since as I mentioned, I'm fairly new to the ways of the parallel transformer world.

Any ideas?

Thanks - Richard, Milwaukee, WI
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. :D

The answer is no. Decimal always reserves space in the string for the leading sign and the decimal placeholder character. The most efficient algorithm for removing them is conversion to string, then using Convert() to remove the space and dot. Just make sure you're not doing this where scale > 0.
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