What is wrong in m

Home » Asterisk Users » What is wrong in m
Asterisk Users 1 Comment

Hi everyone,

What is wrong in below asterisk application? The output should be content of
field booth_status from table booths:

[extension-status]
exten => _X.,1,MYSQL(Connect connid 127.0.0.1 root password my-extensions)
exten => _X.,n,MYSQL(Query allow_call ${connid} SELECT extension_status FROM
mytable WHERE extension=${CALLERID(num)} ORDER BY id DESC LIMIT 1)
exten => _X.,n,NoOp(allow_call is: ${allow_call})

But I get:
*”allow_call is: 4″ *while it should actually be ACTIVE or INACTIVE

I want to read the LAST record found under column “extension” in “mytable”
and do a NoOp for it’s contents. But instead I am getting 4 which I think
refers to the connection ID?!

***There is only one record in my table right now.

Thanks,

One thought on - What is wrong in m

  • The problem is the OP never performs a Fetch of the data returned by the Query…

    From the VoIP-info page for Cmd MYSQL

    MYSQL(Query resultid ${connid} query-string)

    Executes standard MySQL query contained in query-string using established connection identified by ${connid}. Result of query is stored in ${resultid}.

    MYSQL(Fetch fetchid ${resultid} var1 var2 … varN)

    If any rows are available to select, ${fetchid} is set to 1 and a single row is fetched from a result set contained in ${resultid}. The return fields are assigned to ${var1}, ${var2} … ${varN} respectively. If no rows are left to select, ${fetchid} is set to 0 and ${var1}, ${var2} … ${varN} remain unchanged.