Datastage

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
Jones Sam
Participant
Posts: 3
Joined: Thu Oct 17, 2013 6:30 pm

Datastage

Post by Jones Sam »

Hi All,

I have file which has values in a column like below.

col
100
250
300
500

I need to compare if row 1(100)> row 2(250) and row 2(250)> row 3(300)and row 3(300) > row 4 (500),,

Basically I am trying to find if the next row value in a column is greater than the current row value of the same column... If they are increasing from first to last value in the column then send it to a file.
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.

This is not really an ETL task, but you can readily use stage variables in a Transformer stage to keep track of the previous row's value(s) in order to effect your comparison(s).

Another stage variable can be used to monitor your "first to last" (begin true, set to false on any exception) and this could form the constraint on the output link to the file.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Jones Sam
Participant
Posts: 3
Joined: Thu Oct 17, 2013 6:30 pm

Post by Jones Sam »

Hi

we can do this is server job with stage variable as below.

stagevar1=RowProcGetPreviousValue(input.column)
stagevar2=input.column

if(stagevar2<stagevar1) then "yes increasing" else "no"

I tried in parallel job using stage variable but not successful.

Please share your thoughts.

Thanks in advance..
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Stage variables work the same in Parallel and Server, what was 'not successful' about your attempt? What exactly did you try? Did you run the Parallel job on a single node? While not required it does simplify things.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Jones Sam
Participant
Posts: 3
Joined: Thu Oct 17, 2013 6:30 pm

Post by Jones Sam »

Hi Craig

I tried with two stage variables.

PreviousValue = CurrentValue
CurrentValue = input.column

if (CurrentValue < PreviousValue) then ""


Here initially currentvalue does not hold any values then the column values are assigned to previousval stage variable to perform comparision.

I tried with 2 node configuration.
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You must perform the comparison before the "remembering" stage variable is executed.

Code: Select all

svCurrentValue   <---  input column
svIsIncreasing   <---  (svCurrentValue > svPreviousValue)
svPreviousValue  <---  input column
(You don't actually need svCurrentValue.)

Use the value of svIsIncreasing in your constraint logic.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply