Variables

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
Raftsman
Premium Member
Premium Member
Posts: 335
Joined: Thu May 26, 2005 8:56 am
Location: Ottawa, Canada

Variables

Post by Raftsman »

I have a DB2 file that I will append records to. The key is incrementally increased by +1 for every record written. I don't know what the last key value is when I start adding.

My plan was to do a count on the DB2 table, retrieve the last key value and pass it on to the transformer stage incrementing the key by 1. What I am not sure of is, how can I store the last record in a variable from the DB2 read.

Is there an easier way

Thanks.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

A much more robust and acceptable method would be to declare and use a DB2 sequence to do this. You call a DB2 stage as a reference lookup to get the next value from the sequence (and increment the counter). This will work no matter how parallel your job gets since DB2 controls the concurrency and locking of this entry.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you must do it in a parallel job, prefer to use a Surrogate Key Generator stage. The initial value can be picked up be a previous (server?) job and passed into the main job as a job parameter value.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Raftsman
Premium Member
Premium Member
Posts: 335
Joined: Thu May 26, 2005 8:56 am
Location: Ottawa, Canada

Post by Raftsman »

In order to pass variables, how would I go about it.

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Pass variables from where? From outside of the job as a parameter?
Raftsman
Premium Member
Premium Member
Posts: 335
Joined: Thu May 26, 2005 8:56 am
Location: Ottawa, Canada

Post by Raftsman »

Using the Job Sequencer, I am going to create a job that populates either a variable or record with the last DB2 value. The subsequent job will have a parm that contains the value from the previous job.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Correct. You can use PreviousJob.$UserStatus if you chose to store the result in the job's user status area.
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