If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL script for DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-15-04, 22:42
Shinto Shinto is offline
Registered User
 
Join Date: Jan 2004
Posts: 25
SQL script for DB2

hi, I am trying to create a script to create a DB2 database and tables. What i did was write out the SQL codes in notepad and save them under a .SQL extension. Next, i open the script centre and import the sql code and run it.

In the journal, its stated that the running of the script was successful, however when i open the journal report its states that :

CREATE TABLE test
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 "test" was found following "CREATE TYPE TABLE ".
Expected tokens may include: "END-OF-STATEMENT". SQLSTATE=42601

Does anyone know how to solve this problem? Or is it that the steps i am using to create a script is wrong? If possible, can someone post a working copy of a script to create a table here? I just wanna know how it works and how to solve the error message. Attached is a copy of my .sql file.
Attached Files
File Type: sql test.sql (226 Bytes, 61 views)
Reply With Quote
  #2 (permalink)  
Old 01-15-04, 23:26
db2nemo db2nemo is offline
Registered User
 
Join Date: Jan 2004
Location: Canada
Posts: 12
Re: SQL script for DB2

You need to have columns defined when you create table.
For instance:

create table test (Lastname varchar(10), Initial char(1), salary int);

Before the create table command is executed, you may need to do a
connect to <db-name>


Quote:
Originally posted by Shinto
hi, I am trying to create a script to create a DB2 database and tables. What i did was write out the SQL codes in notepad and save them under a .SQL extension. Next, i open the script centre and import the sql code and run it.

In the journal, its stated that the running of the script was successful, however when i open the journal report its states that :

CREATE TABLE test
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 "test" was found following "CREATE TYPE TABLE ".
Expected tokens may include: "END-OF-STATEMENT". SQLSTATE=42601

Does anyone know how to solve this problem? Or is it that the steps i am using to create a script is wrong? If possible, can someone post a working copy of a script to create a table here? I just wanna know how it works and how to solve the error message. Attached is a copy of my .sql file.
Reply With Quote
  #3 (permalink)  
Old 01-15-04, 23:30
db2nemo db2nemo is offline
Registered User
 
Join Date: Jan 2004
Location: Canada
Posts: 12
Re: SQL script for DB2

One more thing, please refer to SQL Reference for full syntax.
Reply With Quote
  #4 (permalink)  
Old 01-16-04, 00:06
Shinto Shinto is offline
Registered User
 
Join Date: Jan 2004
Posts: 25
Re: SQL script for DB2

Please download the copy of my .sql file and refer to it. I already specified columns in it.




Quote:
Originally posted by db2nemo
You need to have columns defined when you create table.
For instance:

create table test (Lastname varchar(10), Initial char(1), salary int);

Before the create table command is executed, you may need to do a
connect to <db-name>
Reply With Quote
  #5 (permalink)  
Old 01-16-04, 01:29
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
I think you need a statement terminatation character (, and you should also commit the changes. Not sure if this is the problem you are having though.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On