Number 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
Marcus426
Participant
Posts: 33
Joined: Wed Sep 09, 2009 1:37 am

Number conversion

Post by Marcus426 »

Hi all,


Can any one help me out with how this can be achieved using Transformer.

I have the following input( Double= type)

1234.89
-1234.00
2345.67


in the output, i need to get the following (fixed length of width 12)

+00001234.89
-00001234.00
+00002345.67


I am using the target type as Decimal(10,2), the negative sign is coming but the positive sign is not (Datastage default for '+' numbers is blank)

Can anyone help me out

Thanks!
Marcus





M
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

From what I've read here, I think you need to handle that manually, perhaps even by declaring the sign as a separate field and explicitly setting it if your number is less than or greater than zero. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

or

Code: Select all

Convert(' ', '+', yourNumberAsString)
bollinenik
Participant
Posts: 111
Joined: Thu Jun 01, 2006 5:12 am
Location: Detroit

Post by bollinenik »

That would add '+' where ever it finds space, even if found more then one space then it will add many '+' symbols so, the best way is.

in derivation, If Coulmn>=0 then '+':StringToDecimal(Columnname,000000000D00), Datatype should be Varchar.

If you are extracting data from Database and writing into a file then use
To_Char(Columnname,'00000000D00') in SELECT query and Add '+' by concating in transformer so that it will give expected result.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

bollinenik wrote:That would add '+' where ever it finds space, even if found more then one space then it will add many '+' symbols
If you map the number to varchar, the only place you will have space is in the leading - in case of positive numbers.
Marcus426
Participant
Posts: 33
Joined: Wed Sep 09, 2009 1:37 am

Post by Marcus426 »

Thanks for the replies guys! I will try them and let you know about the result!




Thanks!
Marcus
Post Reply