If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > using INSERT

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-09-06, 04:49
Konnor Konnor is offline
Registered User
 
Join Date: Mar 2006
Posts: 8
using INSERT

I have just started with DB2 and have set up a small database called 'TEST' with the following table.

Code:
CREATE TABLE Customer
(
	CustomerID	INTEGER NOT NULL,
	Name		VARCHAR(20) NOT NULL
)
when I try to insert any data with something like

Code:
INSERT INTO Customer (CustomerID, Name) VALUES ('12', 'Trev');
It throws up the error

Code:
 A value is not compatible with the data type of its assignment 
target.  Target name is "CUSTOMERID".  SQLSTATE=42821

SQL0408N  A value is not compatible with the data type of its assignment target.  Target name is "CUSTOMERID
I'm fairly sure '12' is a non null integer.

Many thanks,
Reply With Quote
  #2 (permalink)  
Old 03-09-06, 06:12
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
'12' is a string ... 12 is an integer ... Unlike some other databases, DB2 does not do an implicit type conversion between dissimilar data types .. ie , An integer value of say 12 can go into a smallint field or a bigint field, but not into a char field ... A char(5) column's value can go into a varchar(20) column but not into an integer column even if the contents are just numbers ..
INSERT INTO Customer (CustomerID, Name) VALUES (12, 'Trev');

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On