S
S
Sergey2015-09-05 15:39:58
MySQL
Sergey, 2015-09-05 15:39:58

How to call mysql stored procedure from Asterisk via func_odbc?

I want to do something like authorization for support staff, so that before queuing, they enter their pin code. There is a procedure in Mysql, to which I pass ${CULLERID(num)} from the dialplan and ${pincode} entered by the operator. The procedure returns 0 if authorization passed, and 1 if something went wrong. There is still a lot of information in the database, which then gets into the reports, and it is important to know when the employee got in line, when he left.
So, everything I need works with the MYSQL dialplan application, but it is deprecated and will not be in future builds of Asterisk at all.
Current contents of func_odbc.conf

[QUEUE]
dsn=aster-odbc
mode=multirow
writesql=CALL Asterisk_SupportSessionStart(${ARG1},${ARG2})

Fragment externsions.conf where the procedure is called (this is one of the options, I tried a bunch of others, nothing works).
exten => _*99*,1(begin),Read(pincode,${SOUNDPATH}/002-pin,4,10)
exten => _*99*,n,Set(pinvalid=${ODBC_QUEUE(${CULLERID(num)},${pincode})})
exten => _*99*,n,NoOp(${pinvalid})
exten => _*99*,n,GotoIf($[${pinvalid} = 0]?loginok)
exten => _*99*,n,GoTo(begin)
exten => _*99*,n(loginok),NoOp(Access granted)
exten => _*99*,n,HangUp()

I understand that the error is somewhere in the dialplan, I need to further process the response from the database, but I can’t get it.
exten => _*99*,n,NoOp(${pinvalid})- nothing is assigned.
I heard about the functions ODBC_FETCH()and ODBC_FETCH_STATUS(), but I don’t understand how they can be applied, and there is almost no documentation on them. For almost 4 days of proceedings in my head, everything was mixed up.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2015-09-05
@goodcat32

try replacing writesql with readsql
ADD:
in the console you can check
*CLI> odbc read ODBC_QUEUE 12221 142342 exec

Y
Yuri, 2015-09-05
@Erhaver

If you are sure that CALL Asterisk_SupportSessionStart(${ARG1},${ARG2}) returns exactly 1 or 0, try using Set(__pinvalid=

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question