Buildops

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
mydsworld
Participant
Posts: 321
Joined: Thu Sep 07, 2006 3:55 am

Buildops

Post by mydsworld »

Can anyone please tell me how to use a variable (to be used in 'Per-Record' ) to remember its value.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. :D

Initialize the variable in the "before" code, and use it in the "per record" section. If you must, create a static variable. If that term is unfamiliar, enrol in a class to learn some C.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mydsworld
Participant
Posts: 321
Joined: Thu Sep 07, 2006 3:55 am

Post by mydsworld »

I tried that. I have defined the following in Definitions :

#include<stdio.h>
#include<iostream.h>

int x ;
static int y ;

In Pre-Loop :

y = 0 ;

Then in Per-Record :

x = in0.id ;

if(x != y) {
< Taking some action> ;
}
else {
< Take some other action > ;
}

y = x ;

Input is auto-read. But I find control never go to 'else' section though there are such records.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You're going to have to incorporate some debugging statements in your code to capture the actual values of x and y and record them somewhere so that you can work out what's happening.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mydsworld
Participant
Posts: 321
Joined: Thu Sep 07, 2006 3:55 am

Post by mydsworld »

Thanks for your advise.

I even tried that. 'y' is always 0.

I tried another approach. I made the auto-read for input false. Now I am defining the control (looping) in my own. In that case the dbout I am having is where to put the entire code : Pre-Loop,Per-Record,Post-Loop editor.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You only have access to the rows in the per-record code. Therefore you ought not to be writing your own loop. The variable called y is behaving properly like a static variable (I misunderstood your original requirement); try making it a regular variable.
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