Modify Stage Decimal conversion
Moderators: chulett, rschirm, roy
Modify Stage Decimal conversion
Hello!
Is there a way to convert, using modify stage, a string field with the following data:
12034
to decimal 5,2? that is, to 120,34
the key here is using only modify stage because i need to pass the conversion using parameter (i am using one job for several files)
Thanks!
Is there a way to convert, using modify stage, a string field with the following data:
12034
to decimal 5,2? that is, to 120,34
the key here is using only modify stage because i need to pass the conversion using parameter (i am using one job for several files)
Thanks!
--
Juan José Sisti
Juan José Sisti
-
- Premium Member
- Posts: 45
- Joined: Fri Nov 07, 2008 12:22 pm
Re: Modify Stage Decimal conversion
So you mean you would like to convert 12034 which is a varchar to 120.34 which is a decimal(5,2) ?juancho wrote:Hello!
Is there a way to convert, using modify stage, a string field with the following data:
12034
to decimal 5,2? that is, to 120,34
-Hiral
Thanks,
Hiral Chauhan
Hiral Chauhan
-
- Premium Member
- Posts: 45
- Joined: Fri Nov 07, 2008 12:22 pm
Re: Modify Stage Decimal conversion
If you're trying to convert a varchar to decimal in Modify stage you need to use the following function:
decimal_from_string
decimal_col:decimal = decimal_from_string [ceil] (source_col)
For more information on this function you can refer Parallel job developer guide.
Hope that Helps.
-Hiral
decimal_from_string
decimal_col:decimal = decimal_from_string [ceil] (source_col)
For more information on this function you can refer Parallel job developer guide.
Hope that Helps.
-Hiral
Thanks,
Hiral Chauhan
Hiral Chauhan
Re: Modify Stage Decimal conversion
I am trying to use that, but since the string does NOT have any dots nor commas, the function just does not recognize it as the number i need, in fact, it complains that the number does not fit inside the definition, wich is OK since 5,2 is a decimal of the format 999.99.hiral.chauhan wrote:If you're trying to convert a varchar to decimal in Modify stage you need to use the following function:
decimal_from_string
decimal_col:decimal = decimal_from_string [ceil] (source_col)
For more information on this function you can refer Parallel job developer guide.
Hope that Helps.
-Hiral
Then when i try to convert 99999 to decimal 5,2, datastage understands 99999.99 instead of the number i need.
Is there any way to do concatenation or something similar using modify stage functions? because i was thinking maybe two substrings and a constant could do the trick, but i have found no example of it anywhere..
I think that if concatenation is possible i would be able to do
substring(first 3 digits) : "." : substring(last 2 digits)
Any ideas?
--
Juan José Sisti
Juan José Sisti
I don't believe you can manipulate data in the Modify stage, only drop/keep columns and convert data types. You'd need a Transformer to do the division, as far as I know, your syntax would be fine there. Or you can try the Div() function.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
My limitation is that i HAVE to use only modify stage, ill try DIV and get back to you, thanks!chulett wrote:I don't believe you can manipulate data in the Modify stage, only drop/keep columns and convert data types. You'd need a Transformer to do the division, as far as I know, your syntax would be fine there. Or you can try the Div() function.
--
Juan José Sisti
Juan José Sisti
Hmmm... nobody should HAVE to use only a Modify stage, as Ray would say - Resist Stupid Requirements! And I think Div() is only valid in a Transformer. If your only recourse is to divide the number by 100 because a lack of delimiters then I believe your new limitation will be that you'll HAVE to do that in a transformer.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Heh, i know the requirements are silly but its the only way i know that allows me to process metadata using schema files and parameters, i have like 200 raw files i have to read, extract header and trailer, then convert to a dataset and load to an oracle file.chulett wrote:Hmmm... nobody should HAVE to use only a Modify stage, as Ray would say - Resist Stupid Requirements! And I think Div() is only valid in a Transformer. If your only recourse is to divide the number by 100 because a lack of delimiters then I believe your new limitation will be that you'll HAVE to do that in a transformer.
I have everything done automagically, header and trailer extraction and loading to oracle only take two jobs and parameters some parameters, what i was missing is this only step, convert the decimal numbers to something we can use... maybe i'll ask the user to give me the numbers with the dots, but i think that will be hard to do.
The other option is to do 200 jobs...
thanks for the inputs
--
Juan José Sisti
Juan José Sisti