Solved

db2 running sql file

Posted on 2004-03-25
3
7,727 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

805 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