Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 162582) +++ apps/app_voicemail.c (working copy) @@ -3238,6 +3238,22 @@ res = SQLExecDirect(stmt, (unsigned char *)data->sql, SQL_NTS); if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { ast_log(AST_LOG_WARNING, "SQL Direct Execute failed!\n"); + if (res == SQL_ERROR) { + SQLINTEGER nativeerror = 0, numfields = 0; + SQLSMALLINT diagbytes = 0; + unsigned char state[10], diagnostic[256]; + int i; + + SQLGetDiagField(SQL_HANDLE_STMT, stmt, 1, SQL_DIAG_NUMBER, &numfields, SQL_IS_INTEGER, &diagbytes); + for (i = 0; i < numfields; i++) { + SQLGetDiagRec(SQL_HANDLE_STMT, stmt, i + 1, state, &nativeerror, diagnostic, sizeof(diagnostic), &diagbytes); + ast_log(LOG_WARNING, "SQL Execute returned an error %s: %s\n", state, diagnostic); + if (i > 10) { + ast_log(LOG_WARNING, "Oh, that was good. There are really %d diagnostics?\n", (int)numfields); + break; + } + } + } SQLFreeHandle(SQL_HANDLE_STMT, stmt); return NULL; }