Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

db2 running sql file

Posted on 2004-03-25
3
Medium Priority
?
8,131 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 100 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

773 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