Solved

db2 running sql file

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

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

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 (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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

626 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