您好,我正在使用 sqlite3 为我的 AM1808 进行数据库管理。我创建了一个名为 MilkRateChartEditDetail 的新表。
const char *SQL_CREATE_MILKRATECHARTDETAILEDITTABLE =
"CREATE TABLE IF NOT EXISTS MilkRateChartEditDetail ( \
MilkRateChartEditDetailId INTEGER, \
MilkRateChartId INTEGER \
REFERENCES MilkRateChart(MilkRateChartId) \
ON UPDATE RESTRICT ON DELETE RESTRICT, \
EffectiveDate DATE, \
EffectiveShift UNSIGNED TINYINT, \
MilkType UNSIGNED TINYINT, \
RCD_RateChartId UNSIGNED INT,\
SocietyCode STRING, \
RateType STRING, \
FAT FLOAT, \
LRCLR FLOAT, \
SNF FLOAT, \
Solid FLOAT, \
Rate FLOAT, \
NewRate FLOAT, \
UpdatedBy INTEGER \
REFERENCES UserMaster(UsermasterId) \
ON UPDATE RESTRICT ON DELETE RESTRICT, \
UpdatedOn DATE, \
FlagGSM UNSIGNED TINYINT, \
FlagUSB UNSIGNED TINYINT, \
PRIMARY KEY (MilkRateChartEditDetailId))";
现在我正在尝试使用以下查询将数据插入表中。
const char *INSERT_MILKRATECHARTEDITDETAILTABLE =
"INSERT INTO MilkRateChartEditDetail \
(MilkRateChartEditDetailId,MilkRateChartId, \
EffectiveDate,EffectiveShift,MilkType, \
RCD_RateChartId,SocietyCode,RateType, \
FAT,LRCLR,SNF,Solid,Rate,NewRate, \
UpdatedBy,UpdatedOn,FlagGSM,FlagUSB) \
VALUES(NULL,?,?,?,?,?,?,?,?,?,?,?,?,?,NULL,?,?,?)";
我的数据是:
RateChartId : 1
EffectiveDate : 10-12-2012
Shift : E
RateType : FAT
MilkRateChartId : 30
FAT : 11.100000
SNF : 0.000000
Solid : 0.000000
CLR : 0.000000
Updatedby : 1
MilkType : C
Rate : 0.000000
NewRate : 0.000000
我收到一个错误:
插入 MILKRATECHARTEDITDETAILTABLE,条目:'约束失败'
我不明白是什么问题?我怎样才能摆脱这个?