Solved

db2 running sql file

Posted on 2004-03-25
3
7,799 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DB2 Function LISTAGG failing with SQL0440N 1 1,375
db2 how to connect to remote database from my 3 361
How to access tables of DB2 in Excel 8 255
iSeries DB2 - Query with Sub Query? 7 122
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Suggested Courses

710 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