Thread: using INSERT
03-09-06, 05:49 #1Registered User
- Join Date
- Mar 2006
Unanswered: using INSERT
I have just started with DB2 and have set up a small database called 'TEST' with the following table.
CREATE TABLE Customer ( CustomerID INTEGER NOT NULL, Name VARCHAR(20) NOT NULL )
INSERT INTO Customer (CustomerID, Name) VALUES ('12', 'Trev');
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
03-09-06, 07:12 #2Super Moderator
- Join Date
- Aug 2001
'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');
SathyaramVisit the new-look IDUG Website , register to gain access to the excellent content.