Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Posts
    25

    Unanswered: 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 Attached Files

  2. #2
    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>


    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.

  3. #3
    Join Date
    Jan 2004
    Location
    Canada
    Posts
    12

    Re: SQL script for DB2

    One more thing, please refer to SQL Reference for full syntax.

  4. #4
    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.




    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>

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •