Computing.Net > Forums > Disk Operating System > DOS batch with DB2 Statements

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

DOS batch with DB2 Statements

Reply to Message Icon

Name: Tom A.
Date: July 1, 2003 at 03:59:47 Pacific
OS: WIN
CPU/Ram: 512
Comment:

Hi,

I've made a batch in dos, which calls some SQL from DB2. Here is what I do:

db2 CONNECT TO %1 USER %2
db2 EXPORT TO .\output.txt OF DEL MESSAGES .\message.txt SELECT DISTINCT MyColumn FROM MySchema.MyTable ORDER BY MyColumn
db2 COMMIT WORK
db2 CONNECT RESET
db2 TERMINATE


I receive the parameter %1 and %2 from a another "calling" batch, which starts also some db2 environment. that works fine, but I need the MySchema also as a variable. that's why I thought I introduce another select in the batch ("SELECT CURRENT SCHEMA FROM MyTable"), so that it gets me the current schema and I can pass it over to the second select. but I can't manage it to work :(
here is how I think it should be:

db2 CONNECT TO %1 USER %2
db2 SELECT CURRENT SCHEMA FROM MyTable //here should be something to catch the result in lets say %3 variable
db2 EXPORT TO .\output.txt OF DEL MESSAGES .\message.txt SELECT DISTINCT MyColumn FROM %3.MyTable ORDER BY MyColumn
db2 COMMIT WORK
db2 CONNECT RESET
db2 TERMINATE

I don't know if something like that can work, but maybe you have a better idea how to deal with it...
thanks for your time and help,
Tom A.



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: DOS batch with DB2 Statements

Need help with a Dos batch file www.computing.net/answers/dos/need-help-with-a-dos-batch-file/13006.html

Dos batch scripting www.computing.net/answers/dos/dos-batch-scripting/11369.html

HELP ME WITH DOS BATCH FILES LINES PLEASE www.computing.net/answers/dos/help-me-with-dos-batch-files-lines-please/2496.html