/*---------------------------------------------------------------------- | OZN_Statement::Bind +---------------------------------------------------------------------*/ NPT_Result OZN_Statement::Bind(const OZN_TableDescription& desc, const OZN_Properties& properties) { NPT_Result result; NPT_Ordinal bind_index = 1; OZN_Property* property; // verify input params if (properties.GetProperties().GetItemCount() == 0) return NPT_ERROR_INVALID_PARAMETERS; // bind now for (NPT_Cardinal i=0; i<desc.property_descs_count; i++) { property = properties.GetProperty(i); if (!property) continue; if (i == 0) { // bind key, if table is auto assigned, override property type to INTEGER result = BindValue( bind_index++, desc.auto_assign?OZN_PROPERTY_TYPE_INTEGER:desc.property_descs[i].type, property->GetValue().string); NPT_CHECK(result); } else { result = Bind( bind_index++, property); NPT_CHECK(result); } } return NPT_SUCCESS; }
inline int BindParams(sqlite3_stmt *statement, int current, T&&first, Args&&... args) { int code = BindValue(statement, current, first); if (code != SQLITE_OK) return code; code = BindParams(statement, current + 1, std::forward<Args>(args)...); return code; }
void SQLiteQuery::BindValue(const char* name, const SQLiteValue& value) { if (!stmt) throw SQLiteError("invalid query state"); BindValue(sqlite3_bind_parameter_index(stmt, name), value); }