SQLite Forum

Sqlite error 7 handling when delete the record
Login

Sqlite error 7 handling when delete the record

(1) By Mangal Prajapati (V16be1p11) on 2022-01-21 10:19:03 [link] [source]

I have my embedded device which delete record in multiple table at time of log out. But now I am getting sqlite error 7 when it reaches to delete the last table record.

Now last table record not deleted many times and now my device stopped working in live.

I want immediate solution for this problem.

(2) By Gunter Hick (gunter_hick) on 2022-01-21 11:28:58 in reply to 1 [link] [source]

SQLITE_NOMEM (error code 7) is probably because your code is leaking memory to the point where you device is shutting down.

The "immediate solution" is to check your code for memory leaks, maybe by compiling for running on a linux system under valgrind. Or whatever method of leak checking you have available.

You need to provide significantly more details to
- which SQLite release you are using
- how you are calling the SQLite library
- which OS you are running under
- schema of the database
- details of the statements you are running
- details of the calls you are making

(3) By Mangal Prajapati (V16be1p11) on 2022-01-27 07:32:58 in reply to 2 [source]

ans 1 :how to know which sqlite release ? is there any function is there to identify it?

ans 2 & 3: my peer has installed this lib in verix evo/s os.

ans 4,5 and 6: you can see it from below code :

LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB() { DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()"); //Delete no of days(get from tblsetting) data from tblticketTransaction which are already uploaded to server std::string deleteRecordsB4ExtDaysQueryForTicketDB=""; int Result = 0;

//Reprint Transaction
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM TBLREPRINTTICKETTRANSACTIONS WHERE DATE(DTEREPRINTTICKETDATETIME) <='"+strDateBeforeExtensionDays+"' and BUPLOADED = 1 and BMOVED=1 and STRREPRINTTICKETNO NOT IN ( " \
			" SELECT distinct TRT.STRREPRINTTICKETNO " \
			" from TBLREPRINTTICKETTRANSACTIONS  TRT " \
			" INNER JOIN  tblTicketTransactions TR " \
			" ON TRT.STRTICKETNO = TR.STRTICKETNO " \
			" where " \
			" TR.strWayBillNo ='" + strWaybillNo + "');";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeletetblReprintTransationDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT11=%d",Result);
}
//Transactions
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM tblTicketTransactions WHERE DATE(dteTicketDateTime)<='"+strDateBeforeExtensionDays+"' and bUploaded = 1 and bMoved=1 and strWayBillNo!='"+strWaybillNo+"';";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeletetblTicketTransactionsDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT1=%d",Result);
}
//Trips
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM tblTripInfo WHERE DATE(dteTripStartTime) <='"+strDateBeforeExtensionDays+"' and bUploaded = 1 and bUploadedTripEnd = 1 and BMOVEDTRIPSTART=1 and BMOVEDTRIPEND=1 and strWayBillNo!='"+strWaybillNo+"';";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeletetblTripInfoDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT2=%d",Result);
}
//Device Login History
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM tblDeviceLoginHistory WHERE DATE(dteLoginDate) <='"+strDateBeforeExtensionDays+"' and bUploaded = 1 and bUploadedLogout=1 and bLoginMoved=1 and bLogoutMoved=1;";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeletetblDeviceLoginHistoryDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT3=%d",Result);
}
//Device Login History Delete Records :-buploadedLogout=0 and Logout Date is Null or NA and intDeviceLoginId is Not Max Id
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM tblDeviceLoginHistory WHERE DATE(dteLoginDate) <='"+strDateBeforeExtensionDays+"' and bUploaded = 1 and bUploadedLogout=0 and bLoginMoved=1 and bLogoutMoved=0 and (dteLogoutDate IS  NULL OR dteLogoutDate == 'NA' OR dteLogoutDate == '') and INTDEVICELOGINID!=(select max(INTDEVICELOGINID) from TBLDEVICELOGINHISTORY order by 1 desc);";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeletetblDeviceLoginHistoryEmptyLogoutDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT4=%d",Result);
}
//Error Logs
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM tblErrorLogs WHERE DATE(dteErrorDateTime) <='"+strDateBeforeExtensionDays+"' and bUploaded = 1 and strWayBillNo!='"+strWaybillNo+"' and intErrorLogID!=(select MAX(intErrorLogID) from tblErrorLogs where intTicketTypeID=57 ) ;";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeletetblErrorLogsDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT5=%d",Result);
}
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM TBLINSPECTEDTICKETDETAIL WHERE DATE(DTEINSPECTEDTICKETDATETIME) <='"+strDateBeforeExtensionDays+"' and BUPLOADED = 1 and BMOVED = 1 and STRWAYBILLNO !='"+strWaybillNo+"' LIMIT 500;";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeleteInspectedTicketTransactionsDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT12=%d",Result);
}

//Mobile Ticket & Pass
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM TBLMOBILETRANSACTIONS WHERE DATE(DTEUSEDON) <='"+strDateBeforeExtensionDays+"' and BUPLOADED = 1 and BMOVED=1 and STRWAYBILLNO!='"+ strWaybillNo +"';";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeleteTBLMOBILETRANSACTIONSDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT7=%d",Result);
}
//PreFareMatrix
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM TBLPREFAREMATRIXRANGEWISE WHERE DATE(DTEEFFECTIVEON) <='"+strDateBeforeExtensionDays+"' AND BAPPLIED = 0;";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeleteTBLPREFAREMATRIXRANGEWISEDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT8=%d",Result);
}
//Event Logs with Ticket No E1
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM tblEventsLogging WHERE DATE(dteModifiedOn) <='"+strDateBeforeExtensionDays+"' and BUPLOADED = 1 and BMOVED=1 and substr(strTicketNo,11,2) = 'E1' and STRWAYBILLNO!='"+ strWaybillNo +"';";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeletetblEventsLoggingE1DB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT9=%d",Result);
}
//Event Logs with Ticket No E2
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM tblEventsLogging WHERE DATE(dteModifiedOn) <='"+strDateBeforeExtensionDays+"' and BUPLOADED = 1 and substr(strTicketNo,11,2) = 'E2' and STRWAYBILLNO!='"+ strWaybillNo +"';";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeletetblEventsLoggingE2DB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT10=%d",Result);
}
//PENALTYINSPECTIONDETAILS Transaction
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM TBLPENALTYINSPECTIONDETAILS WHERE DATE(DTEPENALTYINSPECTIONDATE) <='"+strDateBeforeExtensionDays+"' and BUPLOADED = 1 and BMOVED = 1 and STRINSPECTORWAYBILLNO !='"+strWaybillNo+"';";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeletePenaltyInspectionDetailsTransactionsDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT11=%d",Result);
}

//HH Problems
if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM TBLHHPROBLEM WHERE DATE(DTEREPORTDATE) <='"+strDateBeforeExtensionDays+"' and BUPLOADED = 1 and bMoved=1 and STRWAYBILLNO!='"+strWaybillNo+"';";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeleteTBLHHPROBLEMDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT6=%d",Result);
}

if(Result == 0)
{
	deleteRecordsB4ExtDaysQueryForTicketDB = "DELETE FROM TBLINSPECTORACTIVITYTRANSACTION WHERE DATE(DTEACTIVITYSTARTTIME) <='"+strDateBeforeExtensionDays+"' and BUPLOADED = 1 and BUPLOADEDEND = 1 and BMOVEDTOBACKSYNCDB = 1 and BMOVEDTOBACKSYNCDBEND = 1 and STRWAYBILLNO !='"+strWaybillNo+"';";
	Result += DeleteUploadedRecordsBeforeExtensionDaysForTicketDB(deleteRecordsB4ExtDaysQueryForTicketDB,_DeleteInspectorActivityTransactionsDB2);
	DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Result of DT13=%d",Result);
}
DBGF_TRACE("AFCS:LogoutStep::DeleteRecordsB4ExtDaysFromTicketDB()::Final Return Result=%d",Result);
return Result;

}