// ***************************************************************************** // * * // * Function: PrivMgrMDTable::deleteWhere * // * * // * This method deletes rows in table based on a WHERE clause. * // * * // ***************************************************************************** // * * // * Parameters: * // * * // * <whereClause> const std::string & In * // * is the WHERE clause (including the keyword WHERE). * // * * // ***************************************************************************** // * * // * Returns: PrivStatus * // * * // * STATUS_GOOD: Statement executed successfully. * // * STATUS_ERROR: Execution failed. A CLI error is put into the diags area. * // * * // ***************************************************************************** PrivStatus PrivMgrMDTable::deleteWhere(const std::string & whereClause) { std::string deleteStmt ("DELETE FROM "); deleteStmt += tableName_; deleteStmt += " "; deleteStmt += whereClause; return CLIImmediate(deleteStmt); }
void MobileRecordStore::deleteRecord(OperationContext* opCtx, const RecordId& recId) { MobileSession* session = MobileRecoveryUnit::get(opCtx)->getSession(opCtx, false); SqliteStatement dataSizeStmt( *session, "SELECT IFNULL(LENGTH(data), 0) FROM \"", _ident, "\" WHERE rec_id = ?;"); dataSizeStmt.bindInt(0, recId.repr()); dataSizeStmt.step(SQLITE_ROW); int64_t dataSizeBefore = dataSizeStmt.getColInt(0); _changeNumRecs(opCtx, -1); _changeDataSize(opCtx, -dataSizeBefore); SqliteStatement deleteStmt(*session, "DELETE FROM \"", _ident, "\" WHERE rec_id = ?;"); deleteStmt.bindInt(0, recId.repr()); deleteStmt.step(SQLITE_DONE); }