Page 1 of 1

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

Posted: Fri Dec 05, 2003 2:54 am
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

Posted: Fri Dec 05, 2003 4:05 am
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.