--- ../clean/asterisk-1.6.2.17-rc2/funcs/func_odbc.c 2010-06-03 21:51:06.000000000 +0200 +++ funcs/func_odbc.c 2011-02-15 16:58:50.000000000 +0200 @@ -170,7 +170,7 @@ } res = SQLExecDirect(stmt, (unsigned char *)sql, SQL_NTS); - if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { + if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO) && (res != SQL_NO_DATA)) { if (res == SQL_ERROR) { int i; SQLINTEGER nativeerror=0, numfields=0; @@ -325,6 +325,10 @@ } } + if (stmt) { + SQLRowCount(stmt, &rows); + } + if (stmt && rows == 0 && ast_str_strlen(insertbuf) != 0) { SQLCloseCursor(stmt); SQLFreeHandle(SQL_HANDLE_STMT, stmt); @@ -347,7 +351,6 @@ } } else if (stmt) { status = "SUCCESS"; - SQLRowCount(stmt, &rows); } AST_RWLIST_UNLOCK(&queries);