Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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 TERMINATEI 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.

![]() |
![]() |
![]() |

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