Results 1 to 6 of 6

Thread: Unable to update my database using insert command

  1. #1
    Join Date
    Jan 2010
    Posts
    37

    Unable to update my database using insert command

    The below insert command does not update my database. Can you tell me where the error is?
    Code:
    DESCRIBE TABLE  names;
    ------------------------------------------------------------------------------
    DESCRIBE TABLE  names
     
                                    DATA type                     COLUMN
    COLUMN name                     schema    DATA type name      Length     Scale Nulls
    ------------------------------- --------- ------------------- ---------- ----- ------
    NAME                            SYSIBM    CHARACTER                   10     0 Yes   
    NUMBER                          SYSIBM    CHARACTER                   10     0 Yes   
    ------------------------------ Commands Entered ------------------------------
    INSERT INTO   NAMES (name, number) VALUES (eeeeee, ed);
    ------------------------------------------------------------------------------
    INSERT INTO   NAMES (name, number) VALUES (eeeeee, ed)
    DB21034E  The command was processed AS an SQL statement because it was NOT a 
    valid Command Line Processor command.  During SQL processing it returned:
    SQL0206N  "EEEEEE" IS NOT valid IN the context WHERE it IS used.  
    SQLSTATE=42703

  2. #2
    Join Date
    May 2008
    Posts
    685

    Re: Unable to update my database using insert command

    Small correction in your insert command like this :

    Code:
    INSERT INTO   NAMES (name, number) VALUES ('eeeeee', 'ed');

  3. #3
    Join Date
    Jan 2010
    Posts
    37

    Re: Unable to update my database using insert command

    But then why doesn't UPDATE work:
    Code:
    ------------------------------ Commands Entered ------------------------------
    DESCRIBE TABLE tab4;
    ------------------------------------------------------------------------------
    DESCRIBE TABLE tab4
     
                                    DATA type                     COLUMN
    COLUMN name                     schema    DATA type name      Length     Scale Nulls
    ------------------------------- --------- ------------------- ---------- ----- ------
    C1                              SYSIBM    CHARACTER                    4     0 Yes   
    C2                              SYSIBM    INTEGER                      4     0 Yes   
     
      2 record(s) selected.
     
    UPDATE TAB4 SET (C1,C2)=(‘NULL’,0);
    ------------------------------------------------------------------------------
    UPDATE TAB4 SET (C1,C2)=(‘NULL’,0)
    DB21034E  The command was processed AS an SQL statement because it was NOT a 
    valid Command Line Processor command.  During SQL processing it returned:
    SQL0206N  "‘NULL’" IS NOT valid IN the context WHERE it IS used.  
    SQLSTATE=42703

  4. #4
    Join Date
    May 2008
    Posts
    685

    Re: Unable to update my database using insert command

    I do not think there is some kind of Null text that you put in your field. You just want your field to be empty, isn't it? In this case, the keyword Null should be used, so do not put apostrophes.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Unable to update my database using insert command

    Your quotes is weird and useless, this is not the same as in the previous example. And in addition, normally, do not do an UPDATE on the primary key of a table.

    / home/zoharn-> db2 "create table T (C1 CHAR (4), C2 INT)"
    DB20000I The SQL command completed successfully.
    / home/zoharn-> db2 "insert into T values ( 'abcd', 9)"
    DB20000I The SQL command completed successfully.
    / home/zoharn-> db2 "update T set (C1, C2) = ( 'NULL', 0)"
    DB20000I The SQL command completed successfully.

  6. #6
    Join Date
    Jan 2010
    Posts
    37

    Re: Unable to update my database using insert command

    Thank you for your answer but the table has no primary key. Basically the table in an intermediate table and so it refers to 2 foreign keys and so doesn't have any specific primary key.

    And for Null, I tried the command by removing the quotes and it worked.

    So for now, thank you all for your concern.

Similar Threads

  1. Unable to update ESET virus signature database
    By Dritan in forum Networking & Security
    Replies: 3
    Last Post: 22-12-2010, 04:59 PM
  2. insert into select statement for database
    By Aidan 12 in forum Software Development
    Replies: 5
    Last Post: 09-03-2010, 10:08 PM
  3. Insert DataGridview into database
    By Neil'o in forum Software Development
    Replies: 3
    Last Post: 24-09-2009, 11:28 AM
  4. DataAdapter.Update command is not updating the database.
    By Kiran123 in forum Software Development
    Replies: 3
    Last Post: 03-02-2009, 06:34 PM
  5. Insert image in access database from vb 6.0
    By Vireshh in forum Software Development
    Replies: 2
    Last Post: 22-01-2009, 09:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,690,102.13588 seconds with 17 queries