static int sql_query(struct sip_msg *msg, char *dbl, char *query, char *res) { str sq; if(pv_printf_s(msg, (pv_elem_t*)query, &sq)!=0) { LM_ERR("cannot print the sql query\n"); return -1; } return sql_do_query((sql_con_t*)dbl, &sq, (sql_result_t*)res); }
int sqlops_do_query(str *scon, str *squery, str *sres) { sql_con_t *con = NULL; sql_result_t *res = NULL; con = sql_get_connection(scon); if(con==NULL) { LM_ERR("invalid connection [%.*s]\n", scon->len, scon->s); goto error; } res = sql_get_result(sres); if(res==NULL) { LM_ERR("invalid result [%.*s]\n", sres->len, sres->s); goto error; } if(sql_do_query(con, squery, res)<0) goto error; return 0; error: return -1; }