Page 1 of 1

Number conversion

Posted: Wed Sep 30, 2009 11:09 am
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

Posted: Wed Sep 30, 2009 12:42 pm
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. :?

Posted: Wed Sep 30, 2009 2:13 pm
by Sainath.Srinivasan
or

Code: Select all

Convert(' ', '+', yourNumberAsString)

Posted: Wed Sep 30, 2009 3:36 pm
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.

Posted: Thu Oct 01, 2009 5:59 am
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.

Posted: Thu Oct 01, 2009 7:58 am
by Marcus426
Thanks for the replies guys! I will try them and let you know about the result!




Thanks!
Marcus