Im using
I doing update statement in SQL with func_odbc.so. The update statement is working fine with no issue. but I wanna away to be able to catch an error if it happens, like a disconnect or network interruption.
Here is my update statement
UPDATE Customers SET AccountBalance = AccountBalance - ${VAL1} WHERE cif = ${ARG1}
My dialPlan function call ( in extention.lua)
local statues = channel.ODBC_ErrorTest(1499):set(10)
One of the thing that I though I can make it work, is by adding TRY and CATCH blook in the SQL statement itself like below, so if there is an error it will return the error number
BEGIN TRY
UPDATE Customers SET AccountBalance = AccountBalance - a WHERE cif = 17399
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber
END CATCH
But when I try to execute this it does not return me an error number when there is a failer, just return an empty string.
So my question is simple, how to handle SQL failer from the dial plan?
For update it should return -1 in case of writesql error.
However you should understand, asterisk is PBX, not something suitable for complex sql check.
Possible workarounds
1) create other table with command, create external script which check it for new "actions" and send back results/error. Check in asterisk after 0.5sec, 1sec etc.
2) create simple rest API and use func_CURL.