Solved

db2 running sql file

Posted on 2004-03-25
3
7,669 Views
Last Modified: 2011-10-03
Hello experts,
I am running IBM DB@ UDB 8.1 on Red Hat Linux 8.0.
I just like to know how can run my sql script from the command line. So far I am trying as follows:

db2 => client.sql
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "END-OF-STATEMENT" was found following
"client.sql".  Expected tokens may include:  "JOIN <joined_table>".
SQLSTATE=42601
db2 =>
0
Comment
Question by:saikat_20042001
  • 2
3 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 10680557
try

outside of the command line processor (CLP)

db2 connect to YOURDATABASENAME

db2 -tvf client.sql  -o client.sql.out


0
 

Author Comment

by:saikat_20042001
ID: 10680871
Hello Lowfatspread,
It did work differently as follows:

[db2inst1@localhost db2inst1]$ db2 connect to EJBDB

   Database Connection Information

 Database server        = DB2/LINUX 8.1.0
 SQL authorization ID   = DB2INST1
 Local database alias   = EJBDB

[db2inst1@localhost db2inst1]$ db2 -tvf client.sql -o client.sql.out
DB21004E  You cannot specify both an input file and a command when invoking
the Command Line Processor.
[db2inst1@localhost db2inst1]$ db2 -tvf client.sql
create table client ( id integer not null, name varchar(20), primary key (id) )
DB20000I  The SQL command completed successfully.

Could you please tell me, if it is possible to create a table from CLP instead of using a script?

Thanks a lot.
0
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 25 total points
ID: 10680983
sorry
db2 -tvf client.sql  -o client.sql.out
should have been
db2 -tvf client.sql  -z client.sql.out

to send the output to the client.sql.out file...

in the clp  enter ? to see all the help info
and then do
? Options;
or
List command options;

to see what settings each of them have

..


yeah sure you can just enter the commands  

e.g.

db2 connect to EJBDB

db2 -t
create table mytable
 (col1 int
,col2 decimal(10,3) not null
,primary key (col1)
)
;


connect reset;

quit;

etc...
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now