You are on page 1of 7

DataStage Scenario # 1

Scenario:
There is a DS Job, in which source is Oracle Enterprise Stage and target is a
Sequential Stage. In the extraction query, WHERE condition is parameterized. That
means every time the Job triggers it will prompt the developer to provide the value
for parameter. The DS Job looks like below.

In Oracle Enterprise Stage:

In Sequential File Stage:

Now the business requirement is there is another file called DEPT_INPUT.TXT


available in E:\DATASTAGE_PRACTICE\SOURCES directory and it contains set of
DEPTNO values. So our DS Job should get trigger as many number of times the
number of records available in DEPT_INPUT.TXT file that are available In the first run
the job should take first recod as parameter value, in second run need to take
second value, etc .
DEPT_INPUT.TXT data:

Solution:
Step 1: Create a Job Sequence that includes the activities as shown below.

Step 2: In ExecCmd_NoRecords activity, need to identify the record count to run the
job as many times the number of records available in DEPT_INPUT.TXT file.

With the specified command we will generally get the output like this.

But we need only the record number so we are going to get this by using user
variable activity in the next step.
Step 3: In UsrVar_NoOfRecords activity use the variable and write the function to get
first value from the output returned in Step 2.

So NoOfRecords variable now holds the value 3 after exuting the specified
command in user variables activity. This output value will be the input for Start Loop
activity because this is nothing but how many times the DS Job should get trigger.

Step 4: In Start Loop activity

Step 5: In ExecCmd_RecordNumber activity, we need to execute a command to


identify the record number for each run, so that when job triggers first time that will
take first record as a parameter value, second time, it will use second record as a
parameter value and so on.

Step 6: In UsrVarRecordNumber activity write the below expression to remove the


unwanted spaces,tabs and field mark, that is deriving from the command from Step
5.

Step 7: In the JobActivity_MainDSJob activity we are calling the main DS Job by


passing the return value from the previous step as a parameter value.

Thats it. There is nothing to define in the End Loop activity. Now try triggering the
DS Job Sequence.
Input data in the Source Oracle DEPT table:

After executing the Job Sequence successfully, see the job status in DS Director and
check output in the target file
E:\DATASTAGE_PRACTICE\TARGETS\DEPT_TARGET.TXT
DS Job Sequence status:

DS Job status(Main):

Output File data:

Happy learning!!
Thogata

Author Nagapratap

You might also like