aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_odbc.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-14 17:29:23 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-14 17:29:23 +0000
commit1fd1c6efa08f6d9fdeda859bcbb4b5ef5f770575 (patch)
treef1c57e8ad114b36b6fde0557558aed2c0a3c55f6 /res/res_odbc.c
parent5786b27d8110c89a4987f66a317919f9967de290 (diff)
Add a direct execute method to res_odbc (closes issue #10722)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82393 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_odbc.c')
-rw-r--r--res/res_odbc.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index c9d3ee700..2fd4c02cf 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -77,6 +77,28 @@ static odbc_status odbc_obj_disconnect(struct odbc_obj *obj);
static int odbc_register_class(struct odbc_class *class, int connect);
+SQLHSTMT ast_odbc_direct_execute(struct odbc_obj *obj, SQLHSTMT (*exec_cb)(struct odbc_obj *obj, void *data), void *data)
+{
+ int attempt;
+ SQLHSTMT stmt;
+
+ for (attempt = 0; attempt < 2; attempt++) {
+ stmt = exec_cb(obj, data);
+
+ if (stmt) {
+ break;
+ } else {
+ obj->up = 0;
+ ast_log(LOG_WARNING, "SQL Exec Direct failed. Attempting a reconnect...\n");
+
+ odbc_obj_disconnect(obj);
+ odbc_obj_connect(obj);
+ }
+ }
+
+ return stmt;
+}
+
SQLHSTMT ast_odbc_prepare_and_execute(struct odbc_obj *obj, SQLHSTMT (*prepare_cb)(struct odbc_obj *obj, void *data), void *data)
{
int res = 0, i, attempt;