这是一个插入函数,我试图在数据库中插入一些记录。
但是在黑白中它不会将记录存储在数据中
这里sqlite3_step和sqlite3_finalize返回OK,但数据库中仍然没有记录。
我还应该为此问题验证什么?
/*Table update for past event*/
void PE_tableUpdate(sqlite3 * PE_db,int nTransLen, char * cTransID, int nDiagLen,char * cDiagID, int nAlarmID, int nPktCounter, int nEventNo, char * cStTime, char * cEndTime, int nECGMode)
{
char * PE_sqlquery;
sqlite3_stmt * PE_stmt;
int PE_Result;
char Up_stat[5] = {'N'};
char Up_stat1[5]= {'D'};
/*Write SQL Query */
PE_sqlquery = "insert into PasteventsTble (TransID,DiagID,AlarmID,PktCounter,EventNo,StrtTime,EndTime,UploadStatus,ECGMode) values (?,?,?,?,?,?,?,?,?)";
/*Run SQL Query*/
PE_Result = sqlite3_prepare_v2 (PE_db, PE_sqlquery, strlen (PE_sqlquery) + 1, &PE_stmt, NULL);
DB_DBG_PRINTF("AlarmCountDBDEBUGStart2 PE_Result:%d",PE_Result);
if((nECGMode == _DEVICE_ARRHYTHMIA_MODE) && (nAlarmID != 100))
nPktCounter = nPktCounter - OFFSET_ARRYTHMIC;
if(nPktCounter < 0)
nPktCounter = 0;
/*Load into DB*/
PE_Result = sqlite3_bind_text(PE_stmt,SQL_TRANSID_INDEX,cTransID,nTransLen,NULL);
PE_Result = sqlite3_bind_text(PE_stmt,SQL_DIAGID_INDEX,cDiagID,nDiagLen,NULL);
PE_Result = sqlite3_bind_int(PE_stmt,SQL_ALARM_INDEX,nAlarmID);
PE_Result = sqlite3_bind_int(PE_stmt,SQL_PKTCOUNTER_INDEX,nPktCounter);
PE_Result = sqlite3_bind_int(PE_stmt,SQL_EVENTNO_INDEX,nEventNo);
PE_Result = sqlite3_bind_text(PE_stmt,SQL_ST_TIME_INDEX,cStTime,HRTIME_NO_OF_CHAR,NULL);
PE_Result = sqlite3_bind_text(PE_stmt,SQL_END_TIME_INDEX,cEndTime,HRTIME_NO_OF_CHAR,NULL);
PE_Result = sqlite3_bind_int(PE_stmt,SQL_ECGMODE_INDEX,nECGMode);
/* Check if the alarm has already been uploaded or not */
if((DOCTOR_SNAPSHOT == nAlarmID) || (nAlarmID != prevAlarmID) )
{
PE_Result = sqlite3_bind_text(PE_stmt,SQL_UPLOAD_INDEX,Up_stat,1,NULL);
prevAlarmID = nAlarmID;
DB_DBG_PRINTF("AlarmCountDBDEBUGStart3 PE_Result:%d",PE_Result);
}
else
{
PE_Result = sqlite3_bind_text(PE_stmt,SQL_UPLOAD_INDEX,Up_stat1,1,NULL);
DB_DBG_PRINTF("AlarmCountDBDEBUGStart4 PE_Result:%d",PE_Result);
}
/*Step into*/
PE_Result = sqlite3_step(PE_stmt);
DB_DBG_PRINTF("AlarmCountDBDEBUGStart PE_Result5:%d",PE_Result);
DB_DBG_PRINTF("AlarmCountDBDEBUGStart Stored");
PE_Result = sqlite3_finalize(PE_stmt);
DB_DBG_PRINTF("AlarmCountDBDEBUGStart PE_Result6:%d",PE_Result);
DB_DBG_PRINTF("PE_tableUpdated");
}