[asterisk-users] Asterisk 1.4.4 VoiceMail ODBC Storage Help

Bruce McAlister bruce.mcalister at blueface.ie
Wed May 2 02:43:52 MST 2007


Hi Remco Post,

Thank you for the tip. I have verified that the permissions are correct for
the table and procedure.

However, I think I may have got to the bottom of the issue now.

What look like was happening is that asterisk was trying to delete any
matching row prior to an insert operation. So, when a user left a message,
for example, message 1, asterisk would attempt to delete message 1 before
inserting it for that user. However, message 1 does not exist at that time
and thus the ODBC driver returns "SQL_NO DATA". 

The same happens when a user checks their voicemail, once an message has
been listened to asterisk moves it to the "Old" directory, that way it can
distinguish between new/old messages. When a user listens to the voicemail,
asterisk then tries to insert the message into the "Old" tree, prior to
doing the insert, asterisk tries to delete the last available message
returned from a select count(*) operation. This message does not exist and
the odbc driver returns "SQL_NO_DATA".

The delete_file function in app_voicemail.c does not accommodate for this
return code SQL_NO_DATA and thus spits out the warning on the console.

I thus changed the following condition in function delete_file in
app_voicemail.c from:

if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
	ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
      SQLFreeHandle (SQL_HANDLE_STMT, stmt);
      ast_odbc_release_obj(obj);
      goto yuck;
}

To:

if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO) && (res !=
SQL_NO_DATA)) {
      ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
      SQLFreeHandle (SQL_HANDLE_STMT, stmt);
      ast_odbc_release_obj(obj);
      goto yuck;
}

This seems to have fixed the problem.

Thanks
Bruce



More information about the asterisk-users mailing list