StringToDecimal
Moderators: chulett, rschirm, roy
StringToDecimal
Hello All,
I have a simple test job where I am trying to convert a string (CHAR 5) into Numeric ( 5,3) oracle table
RowGen-->Transformer-->Oracle
I referred the documentation but still feel that I am doing something fundamentally wrong here
Transformation is StringToDecimal(inputfield)
Output field = Numeric (5,3) Length 5 , Scale 3
Test data has
input , output , expected output
00010 , 10 , 00.010
10010 , 0 , 10.010
33333 , 0 , 33.333
Thank you for reading this .
I have a simple test job where I am trying to convert a string (CHAR 5) into Numeric ( 5,3) oracle table
RowGen-->Transformer-->Oracle
I referred the documentation but still feel that I am doing something fundamentally wrong here
Transformation is StringToDecimal(inputfield)
Output field = Numeric (5,3) Length 5 , Scale 3
Test data has
input , output , expected output
00010 , 10 , 00.010
10010 , 0 , 10.010
33333 , 0 , 33.333
Thank you for reading this .
I think i was able to search for a similar post (searched before but could not find it in first instance)
viewtopic.php?p=253139
I think in when I try to convert something like 33333 ,it is not possible to get the data as 5,3 as there are only 2 chars (digits) on the left of the decimal .
However is there a way to get results where 33333 gets converted into
33.333 in the output where the output column is defined as Numeric 5,3 ?
Thanks for any recommendations
viewtopic.php?p=253139
I think in when I try to convert something like 33333 ,it is not possible to get the data as 5,3 as there are only 2 chars (digits) on the left of the decimal .
However is there a way to get results where 33333 gets converted into
33.333 in the output where the output column is defined as Numeric 5,3 ?
Thanks for any recommendations
As noted, because of the implied decimal you can't simple do the conversion and expect it to know what you want it to do. You'll need to do the conversion and then divide the result by 1000 to move the decimal over three places.
I seem to recall some functions allow you to specify the scale so it can do that for you automatically but this isn't one of them.
I seem to recall some functions allow you to specify the scale so it can do that for you automatically but this isn't one of them.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
I'm not saying that it might be anything that could help you here, just mentioned it more as an academic exercise. One example would be the Server FMT function that allows you to specify a value to "descale" when doing monetary or numeric formatting:
n[m]
n is a number, 0 through 9, that specifies the number of decimal places to display.
If you specify 0 for n, the value is rounded to the nearest integer. The output is padded with zeros or rounded to the nth decimal place, if required.
m specifies how to descale the value:
* A value of 0 descales the value by the current precision.
* A value of 1 through 9 descales the value by m minus the current precision.
If you do not specify m, the default value is 0. The default precision is 4.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The server Oconv() function with "MD"-style conversion can also specify the number of decimal places. In your example.
Code: Select all
Oconv(InLink.MaskedValue, "MD3")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.