Page 1 of 1

Table Name from selected Column

Posted: Thu Dec 28, 2006 11:58 pm
by baglasumit21
I have a table which has columns with table_name and a Flag. I need to fetch the table name with Flag = 'Y' and pass that table name as the table name for the target DB2 stage of my Job. Can any one help me in achieving this

Posted: Fri Dec 29, 2006 12:52 am
by ray.wurlod
Not in the same job.

You would need to obtain the table name in an upstream job and store it somewhere.

In the downstream job make the table name in the target stage a job parameter reference.

In the job sequence that runs both of these jobs, read the table name from its stored location to load a value into the job parameter of the downstream job.

Search the forum for methods of temporarily storing and retrieving values in a job sequence.

Posted: Fri Dec 29, 2006 12:59 am
by rleishman
I don't use DB2, but it should be similar to the Oracle OCI stage.

I believe that what you are trying to do is impossible. It calls for the table name to be dynamically determined at run-time.

The closest you can get to a dynamic table name is to use a Job Parameter (eg. #TABLE_NAME#) in your SQL statement. But then you have to set the value of the parameter, which cannot be done once the job has started.

At best, you could run a job that selected the table name, and then pass it into the next job as a parameter. Search on the following for details of how to pass values between jobs:
- DSSetUserStatus
- $UserStatus

Posted: Fri Dec 29, 2006 8:41 am
by DSguru2B
Keep it simple and visible. As Ray suggested, do it in two jobs. First one fetches the table name. Second one gets that value as a job parameter. Tie them together via a job sequence.

Posted: Sat Dec 30, 2006 7:50 pm
by rleishman
Tap, tap, tap. Is there an echo in here? I thought that's what I said :? Apols to Ray if I repeated his response, but (like the OP) I was unable to read it all.

I guess I wasn't clear enough.

Posted: Sat Dec 30, 2006 9:43 pm
by DSguru2B
I guess i missed out on your last para. Aplogies....
Well no damage done, just re-inforced your advice :wink: