Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specifiying connection details

Status
Not open for further replies.

blakmk

Programmer
Feb 12, 2003
17
GB
Does anyone know of a way to specify which database to connect to when
running scripts (without specifying the database connection details within the script itself)

I know I can use
db2cmd -td@ -f myscript.sql

I basically want to use a batch script to run a number of database
scripts specifying the database name and scriptname at run time
 
blakmk,

does the following point you in the right direction. It's basically a UNIX script but tells you the subtle difference to run as a WINDOWS script. You should be able to use the example given to knock up your parameterised connection.

For OS shell scripts that prefix database commands with “db2”, you can pass parameters in the following manner (for UNIX®):

db2 “select * from employee where empno='$1'”
db2 “select * from employee where empno='$2'”
The above script selects from the EMPLOYEE table where the employee number is equal to the first parameter passed to the script from the OS, and then again with the second parameter passed. (On Windows® platforms, use %1 and %2 instead of $1 and $2, respectively.)


Window is not my platform I am predominantly mainframe or UNIX. Maybe the following link can help you out, which is where I copied the example above from.


Cheers
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top