Set the Stage Variable at the Transformer Level

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
Sairam
Participant
Posts: 42
Joined: Tue Nov 11, 2003 1:09 pm

Set the Stage Variable at the Transformer Level

Post by Sairam »

Hi,

How can we Set the Stage Variable at the transformer level so that it can used for the validation for the next incoming row

Stage Variables:A,Status


first row set A =10

second row IF (A =10) Do Something ..
then set Status =' OK'

Is there any Set function in Basic ?
Klaus Schaefer
Participant
Posts: 94
Joined: Wed May 08, 2002 8:44 am
Location: Germany
Contact:

Post by Klaus Schaefer »

Hello Sairam,

for stage variables you can set derivations in the same way you do it for other derivations on your link output data. So you simply set something like IF INCOM.ROWA = 10 Then 'OK' Else 'NOK'. Since DataStage operates simply sequentially, and stage variables keep their values until being overwritten, you can compare an incoming row value against a value in a stage variable still being there from the last row and not being overwritten yet in the sequence of operation.

Klaus
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Post by raju_chvr »

Or if you really need to know abt Stage Variables, which I assume you are trying to learn. Then,

in the Transformer -> Properties, the first Button on the top menu left to Constraints is the 'Stage Properties' window and in that option you can define Stage variables and give them the default value also.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

When you're assigning values anywhere in DataStage GUI, such as initializing or modifying stage variables, you are using an expression, not a statement.
Therefore there's no requirement for Set (btw there is no Set in DataStage BASIC, though there is a Let).
All you need is an expression that returns the value required.

To accomplish what you ask there's a trick, where you use two stage variables. Stage variable expressions are executed after all input links and before any output links. They are executed in the order in which they are specified.

You need two stage variables as follows.
  • varRequiredValue
    varPreviousValue
varPreviousValue contains the value of the input column. When varRequiredValue is being evaluated, varPreviousValue contains the value of the input column from the previous row. The name of the stage variable varPreviousValue can appear in the derivation expression for varRequiredValue.

Example

Code: Select all

varRequiredValue: 
   If inlink.colname <> varPreviousValue And @INROWNUM <> 1 Then "is different" Else "is the same"
varPreviousValue: 
   inlink.colname
In this example the value of the stage variable varRequiredValue is "is different" if inlink.colname is different in this row than in the previous row, or is "is the same" if inlink.colname is the same in this row as in the previous row. The additional constraint for row 1 obviates the need to initialize the stage variable to the value in the first row.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sairam
Participant
Posts: 42
Joined: Tue Nov 11, 2003 1:09 pm

Post by Sairam »

Hi Ray,

Thanks a lot Ray but I need u r suggestion ,I have designed a job where in I need to pass the Header Information ,Trailer Information and The Detail info , for more validations , to an other job but How can I pass it
a)Thru Job Parameters
b)Write to a file and then call that file on the next job (read I/o DIsk operation)
c) Thru Shared Containers.

Please suggest the best Optimal way

IS IT POSSIBLE TO SET THE JOB PARAMS VALUE AT TRANSFORMER .

Thanks in advance

Sairam
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Post by raju_chvr »

Use your:
Sairam wrote:b)Write to a file and then call that file on the next job (read I/o DIsk operation)
this will be more handly in case the previous job fails/failed to set the Job Parameters for this job.

this is will give you flexibility of restartibility also.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Sairam wrote:Hi Ray,

Thanks a lot Ray but I need u r suggestion ,I have designed a job where in I need to pass the Header Information ,Trailer Information and The Detail info , for more validations , to an other job but How can I pass it
a)Thru Job Parameters
b)Write to a file and then call that file on the next job (read I/o DIsk operation)
c) Thru Shared Containers.

Please suggest the best Optimal way

IS IT POSSIBLE TO SET THE JOB PARAMS VALUE AT TRANSFORMER .

Thanks in advance

Sairam
That's a different question.

You can update stage variables in a Transformer stage.

You can not, ever, anywhere, update a job parameter once its job has started.

How much information has to be parked? You can certainly use a DataStage job to split into header, trailer and detail records. If you want to park them, use three separate sequential files (they're fastest). Or you could do all the processing in three streams in the job that splits them, without using separate jobs.

Shared containers will not be of any value unless the processing, metadata and other non-parameterizable information is identical.
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