Connecting Tech Pros Worldwide Forums | Help | Site Map

DB2 statements in a batch file + redirect output to file

Nananana
Guest
 
Posts: n/a
#1: Jan 17 '07
Hi.
I have 2 DB2 statements:

connect
select

How can I create a batch file and redirect the output to a file?

I would like something like this:

run-select.cmd C:\select-output.txt

TIA


Serge Rielau
Guest
 
Posts: n/a
#2: Jan 17 '07

re: DB2 statements in a batch file + redirect output to file


Nananana wrote:
Quote:
Hi.
I have 2 DB2 statements:
>
connect
select
>
How can I create a batch file and redirect the output to a file?
I would start with an edito.
Then
db2 -tvf <file output.txt

There also is a -z option with the same effect as >

Cheers
Serge


--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Gert van der Kooij
Guest
 
Posts: n/a
#3: Jan 17 '07

re: DB2 statements in a batch file + redirect output to file


In article <1169017820.596611.297250@11g2000cwr.googlegroups. com>,
dnoam@il.ibm.com says...
Quote:
Hi.
I have 2 DB2 statements:
>
connect
select
>
How can I create a batch file and redirect the output to a file?
>
I would like something like this:
>
run-select.cmd C:\select-output.txt
>
TIA
>
>
Check the docs for a full description about how to use the DB2 Command
Line Processor at http://tinyurl.com/yqxcva
Nananana
Guest
 
Posts: n/a
#4: Jan 22 '07

re: DB2 statements in a batch file + redirect output to file


Serge, thanks.
This is what I did:
The batch file has a single line -

db2 connect ...
Quote:
>From the db2 CLP:
C:\>db2 -tvf c:\db2-dup.cmd

DB21007E End of file reached while reading the command.

Please advice.

Thanks and regards,

Serge Rielau wrote:
Quote:
Nananana wrote:
Quote:
Hi.
I have 2 DB2 statements:

connect
select

How can I create a batch file and redirect the output to a file?
I would start with an edito.
Then
db2 -tvf <file output.txt
>
There also is a -z option with the same effect as >
>
Cheers
Serge
>
>
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
>
WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Mark A
Guest
 
Posts: n/a
#5: Jan 22 '07

re: DB2 statements in a batch file + redirect output to file


"Nananana" <dnoam@il.ibm.comwrote in message
news:1169446627.764877.178150@q2g2000cwa.googlegro ups.com...
Quote:
Serge, thanks.
This is what I did:
The batch file has a single line -
>
db2 connect ...
>
Quote:
>>From the db2 CLP:
>
C:\>db2 -tvf c:\db2-dup.cmd
>
DB21007E End of file reached while reading the command.
>
Please advice.
>
Thanks and regards,
When you run a script with "db2 -tvf file-name"
you do not include "db2" in any of the commands within the script. So just
put:

connect to database-name;

in your script (note the semi-colon at the end of each command). This
assumes that you have authority to connect with your current Windows userid,
otherwise you must specify a different user and password in the connect
command.


Nananana
Guest
 
Posts: n/a
#6: Jan 22 '07

re: DB2 statements in a batch file + redirect output to file


Great - thanks.
It works now..


Mark A wrote:
Quote:
"Nananana" <dnoam@il.ibm.comwrote in message
news:1169446627.764877.178150@q2g2000cwa.googlegro ups.com...
Quote:
Serge, thanks.
This is what I did:
The batch file has a single line -

db2 connect ...
Quote:
>From the db2 CLP:
C:\>db2 -tvf c:\db2-dup.cmd

DB21007E End of file reached while reading the command.

Please advice.

Thanks and regards,
>
When you run a script with "db2 -tvf file-name"
you do not include "db2" in any of the commands within the script. So just
put:
>
connect to database-name;
>
in your script (note the semi-colon at the end of each command). This
assumes that you have authority to connect with your current Windows userid,
otherwise you must specify a different user and password in the connect
command.
Nananana
Guest
 
Posts: n/a
#7: Jan 24 '07

re: DB2 statements in a batch file + redirect output to file



Excuse me.. more questions.
Now I want to run this *** from a batch file *** (give the customer a
desktop icon).
This is what I get:

C:\>db2 -tvf test.txt
DB21061E Command line environment not initialized.

Please advice.
TIA

Pierre Saint-Jacques
Guest
 
Posts: n/a
#8: Jan 24 '07

re: DB2 statements in a batch file + redirect output to file


You seem to running this from a standard dos prompt command window,
If you need to use the db2 interface, you must do so from a DB2 Command
Window. which has the db2cmd command interpreter active.
On your dos prompt line, issue: db2cmd

This will open a new window which a DB2 command window and where you wil now
be able to issue:
db2 -tvf test.txt
Just make sure that the test.txt file is in accessible within the PATH
statement you are using.
HTH, Pierre.

--
Pierre Saint-Jacques
SES Consultants Inc.
514-737-4515
"Nananana" <dnoam@il.ibm.coma écrit dans le message de news:
1169622945.640257.164440@k78g2000cwa.googlegroups. com...
Quote:
>
Excuse me.. more questions.
Now I want to run this *** from a batch file *** (give the customer a
desktop icon).
This is what I get:
>
C:\>db2 -tvf test.txt
DB21061E Command line environment not initialized.
>
Please advice.
TIA
>
Closed Thread