DB2 SQL Error: SQLCODE=-803, SQLSTATE=23505, SQLERRMC=1;SLIFE.DATA0005, DRIVER=3

DB2 插入数据到表中时,报如下错误:

DB2 SQL Error: SQLCODE=-803, SQLSTATE=23505, SQLERRMC=1;SLIFE.DATA0005, DRIVER=3

 

SQL如下:

insert into Data0005 (TASK_TYPE_CODE,TASK_TYPE_NAME) values('T0011','飞机票')

经过查看表定义SQL 如下:

CREATE TABLE SLIFE.DATA0005 (
    RKEY                INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1, CACHE 20) NOT NULL,
    TASK_TYPE_CODE      VARCHAR(5) NOT NULL,
    TASK_TYPE_NAME      VARCHAR(50),
    REMARKS             VARCHAR(200),
    SYS_TYPE            INTEGER DEFAULT 1,
    STATUS              INTEGER DEFAULT 1,
    CREATED_DATE        TIMESTAMP DEFAULT CURRENT TIMESTAMP,
    CREATED_USER_PTR    INTEGER,
    UPDATED_TIME        TIMESTAMP DEFAULT CURRENT TIMESTAMP,
    UPDATED_USER_PTR    INTEGER,
    CONSTRAINT PK_RKEY PRIMARY KEY(RKEY)
)
GO
COMMENT ON TABLE SLIFE.DATA0005 IS 'TASK TYPE MASTER'
GO
COMMENT ON COLUMN SLIFE.DATA0005.TASK_TYPE_NAME IS 'SLIFE Change 20->50'
GO
COMMENT ON COLUMN SLIFE.DATA0005.SYS_TYPE IS '0 - 系统内置, 不可修改  1- 用户自定义'
GO

网上找原因 是主键冲突, RKEY为自增主键,表中其最大值为10,手动更改SQL如下,执行成功,

insert into Data0005 (RKEY,TASK_TYPE_CODE,TASK_TYPE_NAME) values(11,'T0011','飞机票')

 

具体原因也许是主键是索引的缘故吧,没搞懂。

 

 

你可能感兴趣的:(driver)