Page 1 of 1

Variables

Posted: Fri Nov 17, 2006 8:46 am
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.

Posted: Fri Nov 17, 2006 8:49 am
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.

Posted: Fri Nov 17, 2006 9:15 am
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.

Posted: Fri Nov 17, 2006 10:14 am
by Raftsman
In order to pass variables, how would I go about it.

Thanks

Posted: Fri Nov 17, 2006 10:30 am
by ArndW
Pass variables from where? From outside of the job as a parameter?

Posted: Fri Nov 17, 2006 10:39 am
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.

Posted: Fri Nov 17, 2006 11:40 am
by ray.wurlod
Correct. You can use PreviousJob.$UserStatus if you chose to store the result in the job's user status area.