Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , ,

Sponsored Links


Unable to update my database using insert command

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 13-02-2010
Member
 
Join Date: Jan 2010
Posts: 37
Unable to update my database using insert command

Sponsored Links
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

Reply With Quote
  #2  
Old 13-02-2010
fellah's Avatar
Member
 
Join Date: May 2008
Posts: 689
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');
Reply With Quote
  #3  
Old 13-02-2010
Member
 
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
Reply With Quote
  #4  
Old 13-02-2010
fellah's Avatar
Member
 
Join Date: May 2008
Posts: 689
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.
Reply With Quote
  #5  
Old 13-02-2010
MindSpace's Avatar
Member
 
Join Date: Feb 2008
Posts: 1,839
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.
Reply With Quote
  #6  
Old 13-02-2010
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Unable to update my database using insert command"
Thread Thread Starter Forum Replies Last Post
Unable to update ESET virus signature database Dritan Networking & Security 3 22-12-2010 03:59 PM
Is it possible to insert value of TextBox into Sql database using C sharp? Sarfaraj Khan Software Development 5 05-01-2010 10:58 AM
Insert DataGridview into database Neil'o Software Development 3 24-09-2009 11:28 AM
DataAdapter.Update command is not updating the database. Kiran123 Software Development 3 03-02-2009 05:34 PM
Insert image in access database from vb 6.0 Vireshh Software Development 2 22-01-2009 08:06 PM


All times are GMT +5.5. The time now is 06:00 PM.