diff -ur ../clean/asterisk-1.6.2.16.1/funcs/func_odbc.c ./funcs/func_odbc.c --- ../clean/asterisk-1.6.2.16.1/funcs/func_odbc.c 2010-06-03 21:51:06.000000000 +0200 +++ ./funcs/func_odbc.c 2011-02-06 15:55:59.000000000 +0200 @@ -325,9 +325,7 @@ } } - if (stmt && rows == 0 && ast_str_strlen(insertbuf) != 0) { - SQLCloseCursor(stmt); - SQLFreeHandle(SQL_HANDLE_STMT, stmt); + if (!stmt && rows == 0 && ast_str_strlen(insertbuf) != 0) { for (dsn = 0; dsn < 5; dsn++) { if (!ast_strlen_zero(query->writehandle[dsn])) { obj = ast_odbc_request_obj(query->writehandle[dsn], 0);