catching previous row.

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Nagaraj
Premium Member
Premium Member
Posts: 383
Joined: Thu Nov 08, 2007 12:32 am
Location: Bangalore

catching previous row.

Post by Nagaraj »

I have a requirement.

Code: Select all

skey(sorted)       col_a       col_b 
1                    1          3
2                    3          2
3                    2          3
4                    1          5

Output is 

Prev End_total
0       4(col_a+col_b)
4       9(previous End_total + col_a col_b)
9       14 (previous End_total + col_a col_b)
14     20 (previous End_total + col_a col_b)

Using Stage variables 

i am getting output as 

Prev End_total
0      4
4      5
5      5
5      6

I have used Getpreviousrowval() function to catch the prev values in the variables and substituted in 

sv1 > RowProcGetPreviousValue(curr_a + curr_b) (Prev)
sv1+ curr_a + curr_b > (End_total)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Please don't create polls here. The poll was basically: can this be accomplished? Yes/No/Maybe.

Can you be more specific about your question and/or issue? I don't really see what problem you are having from all that you posted. Where you say "Output is" do you actually mean "Output should be"?
-craig

"You can never have too many knives" -- Logan Nine Fingers
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Post by fmou »

Where you say "Output is" do you actually mean "Output should be"?
yeah, i believe so.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I believe so too but looking for the OP to confirm... and to be more precise with their language. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Nagaraj
Premium Member
Premium Member
Posts: 383
Joined: Thu Nov 08, 2007 12:32 am
Location: Bangalore

Post by Nagaraj »

output should be

Code: Select all

Prev End_total
0       4 (col_a+col_b)
4       9 (previous End_total + col_a col_b)
9      14 (previous End_total + col_a col_b)
14     20 (previous End_total + col_a col_b) 
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

So you're looking for a running, or cumulative, total. This is easily accomplished with stage variables. Many examples have already been posted on DSXchange.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm... I thought one of the "RowProc" routines (there are more than one) did running totals. Are those SDK routines officially documented in the supplied pdfs? (digs around) Ah, they are, found'em. Oddly enough, it is called RowProcRunningTotal. :wink:

As noted, this can also be done using properly ordered stage variables.
-craig

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