我的表结构如下图
CREATE TABLE MCARE_HOUSE_DETAILS (
HOUSE_DTL_ID VARCHAR(20) NOT NULL,
HOUSE_SRV_DTL_ID VARCHAR(20) NULL,
WARD_ID VARCHAR(20) NOT NULL,
HOUSE_NO VARCHAR(50) NOT NULL,
HOUSE_NAME VARCHAR(50),
ADDRESS VARCHAR(300),
HOUSE_TYPE VARCHAR(20) ,
ELECTRICITY CHAR(1),
LATRINE_TYPE VARCHAR(20) ,
WATER_SOURCE VARCHAR(20) ,
WATER_STORAGE_FACILITY INTEGER,
WASTE_DISPOSAL_SOLID VARCHAR(20) ,
WASTE_DISPOSAL_LIQUID VARCHAR(20) ,
SURVEY_DATE CHAR(10),
CREATED_USER_ID VARCHAR(20) ,
CREATED_DATE CHAR(19),
MODIFIED_USER_ID VARCHAR(20) ,
MODIFIED_DATE CHAR(19),
UPLOAD_STATUS CHAR(1),
INSTITUTION_ID VARCHAR(10),
NEW_WARD_ID VARCHAR(20) ,
NEW_HOUSE_NO VARCHAR(50),
UNIQUE_HOUSE_NO VARCHAR(50),
PRIMARY KEY (HOUSE_DTL_ID))
插入查询块如下
openDB=DBConnection.getInstance(context).openDataBase();
SQLiteStatement statement = openDB.compileStatement("INSERT INTO MCARE_HOUSE_DETAILS (HOUSE_DTL_ID,WARD_ID,HOUSE_NO) VALUES(?,?,?);");
statement.bindString(1,houseId);
statement.bindString(1,wardId);
statement.bindString(2,houseNumber);
statement.executeInsert();
插入的值为 houseId=bp,wardId=199,houseNumber=Test
我在插入时收到以下错误
:android.database.sqlite.SQLiteConstraintException:错误代码19:约束失败
我什至无法在此表中插入一行
请帮忙。