Page 1 of 1

query in a column

Posted: Tue Sep 18, 2007 11:11 am
by DSbox61
hi folks,

I need some help with this tricky requirement. I have a table and one of its columns will have a query. I need to execute that query i.e. the column of the table.

Example: there is a column called XQUERY and its value could be 'select * from emp'. Now, I need to execute this query and populate my result. And the gud part is that there would be only one record at a time i.e. i need to execute only one query, but it would come as a value of the column.

How can i do this in datastage? I know i can do this using unix script and db2 -tvf commands. but is this possible in datastage?

thnx for the help guys....

Re: query in a column

Posted: Tue Sep 18, 2007 11:15 am
by DeepakCorning
Assuming that the query stored in the table is a uniform query (you know the output of it - means what format the results will be) you can develop two jobs. The second one gets called from the first one. The first one runs and stores the query in a variable and passes it on to the next job. the next job uses this variable as user defined sql and runs the SQL.

Posted: Tue Sep 18, 2007 11:35 am
by DSbox61
Hi Deepak, what do you mean here by a variable? when i fetch that query using DB2 stage, now where should i send this resultset? should i send it to a file or a job sequence? what stage should i use for this variable?

Posted: Tue Sep 18, 2007 11:40 am
by DeepakCorning
Design the second job in a way that the first stage of the job will run a job variable as a user defined SQL. Now when u call this job from the master job u will have to specify the job variable. Pass the query column as the variable when u call the second job.

You can also write a routine which will return the column query as the return value and then u can use this return value in the user defined SQL tab in the job.

Posted: Tue Sep 18, 2007 4:36 pm
by ray.wurlod
Investigate the SDK utility routine UtilityRunJob().

Posted: Wed Sep 19, 2007 10:28 am
by DSbox61
Hi Ray,

How would the UtilityRunJob help? It just provides me the job information. IS this info to make use of it in calling my second job? :?

Posted: Wed Sep 19, 2007 4:47 pm
by ray.wurlod
Pass the query to the job run under control as a job parameter. Use a reference to this job parameter as the user-defined SQL in that job.

Posted: Wed Sep 19, 2007 10:08 pm
by sachin1
my question is that your table contains a column in which query is stored, is this query static i mean to say same query always or dynamic which means that table columns contains different query for each execution, if it is different then how are you populating your columns viewed through datastage.