From 854f3f642ab593b1fe313fd631a2fea8ff395afb Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 21 Jan 2009 18:44:07 +0000 Subject: [PATCH] FSCORE-276 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11331 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_odbc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/switch_odbc.c b/src/switch_odbc.c index 502f7014ba..806fbd44ba 100644 --- a/src/switch_odbc.c +++ b/src/switch_odbc.c @@ -32,6 +32,10 @@ #include #include +#if (ODBCVER < 0x0300) +#define SQL_NO_DATA SQL_SUCCESS +#endif + struct switch_odbc_handle { char *dsn; char *username; @@ -222,6 +226,10 @@ static int db_is_up(switch_odbc_handle_t *handle) result = SQLExecute(stmt); + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) { + goto error; + } + SQLRowCount (stmt, &m); rc = SQLNumResultCols (stmt, &nresultcols); if (rc != SQL_SUCCESS){ @@ -351,7 +359,7 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec_detailed(c result = SQLExecute(stmt); - if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) { + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO && result != SQL_NO_DATA) { goto error; } @@ -366,8 +374,12 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec_detailed(c int y = 0; int done = 0; - if (!(result = SQLFetch(stmt)) == SQL_SUCCESS) { - err++; + result = SQLFetch(stmt); + + if (result != SQL_SUCCESS) { + if (result != SQL_NO_DATA){ + err++; + } break; }