is an undefined name. SQLSTATE=42704

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rennet17
    New Member
    • Apr 2012
    • 5

    is an undefined name. SQLSTATE=42704

    I am trying to create a table from an existing table and i need the existing tables data in my new table, So i submitted the following statement


    insert into first (select * from <old_table>

    but i am getting the following error

    Error during Prepare
    S0002(-204)[IBM][CLI Driver][DB2/AIX64] SQL0204N "RNOEL03.FI RST" is an undefined name. SQLSTATE=42704


    can you please help

    Thanks
  • rennet17
    New Member
    • Apr 2012
    • 5

    #2
    insert into first (select * from <old_table>)

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      The correct syntax to create a table from a SELECT query is this:
      Code:
      SELECT *
      INTO newTable
      FROM oldTable

      Comment

      • rennet17
        New Member
        • Apr 2012
        • 5

        #4
        i did that
        select * into st from <old_table>

        but i am getting this

        error Error during Prepare
        42601(-104)[IBM][CLI Driver][DB2/AIX64] SQL0104N An unexpected token "into st from <old_table>" was found following "select * ". Expected tokens may include: "<table_exp r>". SQLSTATE=42601

        Comment

        • rennet17
          New Member
          • Apr 2012
          • 5

          #5
          I working on AQT tool on DB2

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            You actually put in <>? I thought you were just doing that in place of the actual table name. Remove them, they are not correct syntax.

            Comment

            • rennet17
              New Member
              • Apr 2012
              • 5

              #7
              No i did not put < > i just replaced the real table name with that.

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                It looks like DB2 does not support the SELECT INTO syntax to create tables. You'll have to use two SQL statements. One create statement and one insert statement.

                Comment

                Working...