By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,007 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,007 IT Pros & Developers. It's quick & easy.

DOS Batch file to run a Stored Procedure

P: 2
I have a clean up proceudre that needs to be scheduled on weekly basis. My company owns a schedular that can kick off MS DOS Batch file for me.

If only I can execute the stored procedure from a .BAT file my work will be done.

I tried I created a simple batch file which uses DB2 CLP to execute the stored procedure, but I'm getting this error "SQL1024N A database connection does not exist. SQLSTATE=08003" when I run this batch file.

Batch file contains:

db2cmd -c -w -i db2 connect to DBNAME user ***** using *****
db2cmd -c -w -i db2 call PROCSHEMA.PROCNAME(INARG1, INARG2,?,?,?,?,?) >ProcOutput.txt

Please let me know how I can exstablish a connection or is there any better way to create a bacth file that can do a simple task like executing a procedure.

Any help is greatly appreciated. Thanks
Oct 5 '07 #1
Share this Question
Share on Google+
2 Replies

P: 2
The environment is DB2 UDB 8.2 and a client is installed on the local m/c
Oct 5 '07 #2

P: 1
Try running the connect and the SP call in one db2 script and have the scheduler run the CLP with the script file...

connect to DBNAME user ***** using *****;
db2cmd /c /w db2 -tvf script.sql -z script.out
Nov 6 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.