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

Loading query statements from file

P: n/a
Hi, guys

I am new to Db2. Here is my first trivial question.
Let's say I have a simple SELECT statement in a text file called
query1.txt, I want to load the statement from that file and run it in
the interactive shell.
What do I do ? Load , Export, Import ? Could someone just give me a
example ?

Furthermore, if I want to store the output in a new file , what
commands should I use ?
Thank you so much. :)

Feb 1 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
kO********@gmail.com wrote:
Let's say I have a simple SELECT statement in a text file called
query1.txt, I want to load the statement from that file and run it in
the interactive shell.
Furthermore, if I want to store the output in a new file , what
commands should I use ?
db2 -tvf query.txt -z query.out

will process a script contained in query.txt and put output in query.out.

Statements in query should be terminated with ; - this can be changed as well -
see output of:

db2 ? options

command.

DB2 commands can also be included - for example:

connect
to
sample;
select
*
from
org
;
connect
reset
;

shows that statement can span multiple lines. You can change terminator to any
other character not in the script as well.
Jan M. Nelken
Feb 1 '07 #2

P: n/a
In article <52*************@mid.individual.net>,
Un**********@Invalid.Domain says...
kO********@gmail.com wrote:
Let's say I have a simple SELECT statement in a text file called
query1.txt, I want to load the statement from that file and run it in
the interactive shell.
Furthermore, if I want to store the output in a new file , what
commands should I use ?

db2 -tvf query.txt -z query.out

will process a script contained in query.txt and put output in query.out.

Statements in query should be terminated with ; - this can be changed
as well -
see output of:

db2 ? options

command.
k0dreaming, you can find more info about it in the docs at
http://tinyurl.com/27pcs6
Feb 2 '07 #3

P: n/a

What I actually want to do is to load the file when I am actually in
the db2 shell already (i.e. db2 =), not from the unix shell.

Any ideas ?

Thanks a lot !



On Feb 1, 8:54 pm, Gert van der Kooij <nom...@invalid.nlwrote:
In article <52fbqtF1ogq7...@mid.individual.net>,
Unknown.U...@Invalid.Domain says...


kOdream...@gmail.com wrote:
Let's say I have a simple SELECT statement in a text file called
query1.txt, I want to load the statement from that file and run it in
the interactive shell.
Furthermore, if I want to store the output in a new file , what
commands should I use ?
db2 -tvf query.txt -z query.out
will process a script contained in query.txt and put output in query.out.
Statements in query should be terminated with ; - this can be changed
as well -
see output of:
db2 ? options
command.

k0dreaming, you can find more info about it in the docs athttp://tinyurl.com/27pcs6- Hide quoted text -

- Show quoted text -

Feb 2 '07 #4

P: n/a
Barry wrote:
What I actually want to do is to load the file when I am actually in
the db2 shell already (i.e. db2 =), not from the unix shell.
Use Copy/Paste feature of your OS/shell.

Jan M. Nelken
Feb 2 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.