|
| ||||||||||
| Tags: database, db2, insert command, sql, update database |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Unable to update my database using insert command
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
| ||||
| ||||
| 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
| |||
| |||
| 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
| ||||
| ||||
| 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
| ||||
| ||||
| 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
| |||
| |||
| 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. |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |