/* * Delete a row from the specified table * _h: structure representing database connection * _k: key names * _o: operators * _v: values of the keys that must match * _n: number of key=value pairs */ int db_unixodbc_delete(const db_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v, const int _n) { CON_RESET_CURR_PS(_h); /* no prepared statements support */ return db_do_delete(_h, _k, _o, _v, _n, db_unixodbc_val2str, db_unixodbc_submit_query); }
/** * Delete a row from the specified table * \param _h structure representing database connection * \param _k key names * \param _o operators * \param _v values of the keys that must match * \param _n number of key=value pairs * \return zero on success, negative value on failure */ int db_sqlite_delete(const db_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v, const int _n) { int ret; sqlite3_stmt* stmt; #ifdef SQLITE_BIND db_ps_t ps; CON_SET_CURR_PS(_h, &ps); #else CON_RESET_CURR_PS(_h); #endif ret = db_do_delete(_h, _k, _o, _v, _n, db_sqlite_val2str, db_sqlite_submit_dummy_query); if (ret != 0) { return ret; } again: ret=sqlite3_prepare_v2(CON_CONNECTION(_h), query_holder.s, query_holder.len, &stmt, NULL); if (ret==SQLITE_BUSY) goto again; if (ret!=SQLITE_OK) LM_ERR("failed to prepare: (%s)\n", sqlite3_errmsg(CON_CONNECTION(_h))); #ifdef SQLITE_BIND if (db_sqlite_bind_values(stmt, _v, _n) != SQLITE_OK) { LM_ERR("failed to bind values\n"); return -1; } #endif again2: ret = sqlite3_step(stmt); if (ret==SQLITE_BUSY) goto again2; if (ret != SQLITE_DONE) { LM_ERR("insert query failed %s\n", sqlite3_errmsg(CON_CONNECTION(_h))); return -1; } sqlite3_finalize(stmt); return 0; }
/*! * \brief Delete a row from the specified table * \param _h structure representing database connection * \param _k key names * \param _o operators * \param _v values of the keys that must match * \param _n number of key=value pairs * \return 0 on success, negative on failure */ int db_postgres_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v, const int _n) { db1_res_t* _r = NULL; int tmp = db_do_delete(_h, _k, _o, _v, _n, db_postgres_val2str, db_postgres_submit_query); if (db_postgres_store_result(_h, &_r) != 0) LM_WARN("unexpected result returned"); if (_r) db_free_result(_r); return tmp; }
/* * Delete a row from the specified table * _con: structure representing database connection * _k: key names * _o: operators * _v: values of the keys that must match * _n: number of key=value pairs */ int db_postgres_delete(const db_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v, const int _n) { db_res_t* _r = NULL; CON_RESET_CURR_PS(_h); /* no prepared statements support */ int tmp = db_do_delete(_h, _k, _o, _v, _n, db_postgres_val2str, db_postgres_submit_query); if (db_postgres_store_result(_h, &_r) != 0) LM_WARN("unexpected result returned"); if (_r) db_free_result(_r); return tmp; }
/* * Delete a row from the specified table * _h: structure representing database connection * _k: key names * _o: operators * _v: values of the keys that must match * _n: number of key=value pairs */ int db_oracle_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v, int _n) { query_data_t cb; int rc; if (!_h || !CON_TABLE(_h)) { LM_ERR("invalid parameter value\n"); return -1; } cb._rs = NULL; cb._v = _v; cb._n = _n; cb._w = NULL; cb._nw = 0; CON_ORA(_h)->pqdata = &cb; CON_ORA(_h)->bindpos = 0; rc = db_do_delete(_h, _k, _o, _v, _n, db_oracle_val2str, db_oracle_submit_query); CON_ORA(_h)->pqdata = NULL; /* paranoid for next call */ return rc; }
/** * Delete a row from the specified table * \param _h structure representing database connection * \param _k key names * \param _o operators * \param _v values of the keys that must match * \param _n number of key=value pairs * \return zero on success, negative value on failure */ int db_mysql_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v, const int _n) { return db_do_delete(_h, _k, _o, _v, _n, db_mysql_val2str, db_mysql_submit_query); }