Needed decimal value in 99,999,999 format

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
HemaV
Participant
Posts: 63
Joined: Wed Jan 09, 2008 1:38 am
Location: Bangalore

Needed decimal value in 99,999,999 format

Post by HemaV »

Hi All,

I need to perform sum(col1) group by col2 in oracle and that value i need to fetch as comma delimited like 99,999,999.

my source column col1 is decimal(22,5) and my target column is varchar2(10).

Is there any way to do this in transformer?

Thanks in Advance,
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Only by writing your own function.

You can do it in a BASIC Transformer stage using the Fmt() function or the Oconv() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
BI-RMA
Premium Member
Premium Member
Posts: 463
Joined: Sun Nov 01, 2009 3:55 pm
Location: Hamburg

Post by BI-RMA »

It is possible by using a combination of stage-variables and loop-variables.

Code: Select all

svInput(Varchar(10)):AsInteger(Column))
svLen(Smallint):Len(AsInteger(Column))
svLoops(Smallint):Ceil(svLen/3.0) - dividend needs to be in float-format!

Loop While @ITERATION <= svLoops 

lvIndex(Smallint): If @ITERATION = 1 Then svInput [1,Mod(svlaenge,3)] Else If @ITERATION = 2 Then lvPart +1 Else lvPart +3
lvOutput: If @ITERATION = 1 and svLoops > @ITERATION Then svInput [1, lvPart]:"," Else If @ITERATION > 1 and svLoops > @ITERATION then lvOutput: svInput [ lvPart,3]:"," Else lvOutput: svInput [ lvPart,3]
Maybe this can be slightly optimized. Feel free.
Too complicated? See Ray's post!
"It is not the lucky ones are grateful.
There are the grateful those are happy." Francis Bacon
BI-RMA
Premium Member
Premium Member
Posts: 463
Joined: Sun Nov 01, 2009 3:55 pm
Location: Hamburg

Post by BI-RMA »

I forgot the filter-condition: @ITERATION = svLoops .
"It is not the lucky ones are grateful.
There are the grateful those are happy." Francis Bacon
HemaV
Participant
Posts: 63
Joined: Wed Jan 09, 2008 1:38 am
Location: Bangalore

Post by HemaV »

Thanks for all the replies. I will try this solution.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I've always used FMT() for requirements like this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
BI-RMA
Premium Member
Premium Member
Posts: 463
Joined: Sun Nov 01, 2009 3:55 pm
Location: Hamburg

Post by BI-RMA »

chulett wrote:I've always used FMT() for requirements like this.
Yes, Craig. Ray mentioned that as well. But this was a requirement for a Parallel Job.
"It is not the lucky ones are grateful.
There are the grateful those are happy." Francis Bacon
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Which means you simply include it in a BASIC Transformer as Ray mentioned. And I mentioned it to reinforce Ray's mention. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply