Run SQL queries in DB2 and output to file

Hi,

I new to Unix and scripting. Following is my requirement. Can someone tell me whether its possible or not. Also please let me know how to proceed further if this is possible.

List of queries are stored in a file. For example, I have to run a query like this:
Select * from &XYZ where field1=&ABC

where &XYZ is the file name that needs to be taken from another file TEMP1. And &XYZ is the DB2 file name. We need to connect to DB2 database from Unix system.
where &ABC is the entry parameter which needs to be given

Finally the result needs to be stored in a temporary file.

Is is possible to execute a query with these conditions.

Database used is DB2
and System is AIX UNIX