markgargan
Programmer
Hey folks,
I'm currently trying to write a db2 script.
I've got a number of commands back to back like follows
db2 attach to db2;
db2 connect to sample;
db2 -r authors.txt select * from authors;
db2 disconnect sample;
db2 detach;
db2 terminate;
However as soon as the script tries to invoke the first command I get the following error:-
DB21061E Command line environment not initialised
I've moved all the commands to a .db2 file removing the
'db2' prefix from each and then called them using the
db2cmd.exe executable.
This works however the most important part of the script is
the redirection.
I've read some of the docs on the CLP and it says :-
"Maintaining Database Connections
Each time that db2 is invoked, a new front-end process is started. The back-end process is started by the first db2 invocation, and can be explicitly terminated with TERMINATE. All front-end processes with the same parent are serviced by a single back-end process, and therefore share a single database connection.
For example, the following db2 calls from the same operating system command prompt result in separate front-end processes sharing a single back-end process, which holds a database connection throughout: "
Basically that by invoking DB2 attach that the db2bp process should maintain the connection.
Does anyone know how to get around this issue? As it seems fairly fundamental to writing db2 scripts.
Thanks,
Mark.
I'm currently trying to write a db2 script.
I've got a number of commands back to back like follows
db2 attach to db2;
db2 connect to sample;
db2 -r authors.txt select * from authors;
db2 disconnect sample;
db2 detach;
db2 terminate;
However as soon as the script tries to invoke the first command I get the following error:-
DB21061E Command line environment not initialised
I've moved all the commands to a .db2 file removing the
'db2' prefix from each and then called them using the
db2cmd.exe executable.
This works however the most important part of the script is
the redirection.
I've read some of the docs on the CLP and it says :-
"Maintaining Database Connections
Each time that db2 is invoked, a new front-end process is started. The back-end process is started by the first db2 invocation, and can be explicitly terminated with TERMINATE. All front-end processes with the same parent are serviced by a single back-end process, and therefore share a single database connection.
For example, the following db2 calls from the same operating system command prompt result in separate front-end processes sharing a single back-end process, which holds a database connection throughout: "
Basically that by invoking DB2 attach that the db2bp process should maintain the connection.
Does anyone know how to get around this issue? As it seems fairly fundamental to writing db2 scripts.
Thanks,
Mark.