How to Get the Max ID of the Target Table in the Job

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
asvictor
Participant
Posts: 31
Joined: Tue Sep 02, 2003 3:06 am
Location: Singapore
Contact:

How to Get the Max ID of the Target Table in the Job

Post by asvictor »

Hi,

I have a job where I extract the Results and get the Max ID of the Target Table and add 1 to write to the Target. I have taken the MAx id and add 1 to my Job. But since the Target File is a Big file, i am not able to Get the max id. IS ther any way to get the max Id of the Target table?

Cheers
Victor Auxilium
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The usual way is to rely upon indexing in the target database, and to use a user-defined SQL expression such as

Code: Select all

SELECT MAX(keycolumn) FROM tablename;
This always returns one row, which you can pre-load into a hashed file (with a constant as the key value) or other temporary location for subsequent use in your job. Or you could pick it up in a Routine that is used to initialize the value of a stage variable that is incremented within your job.
There are many possible solutions, but most start with that SQL statement.
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