*SOLVED* AGI+Exec+Mysql(Query....) syntax help

Hi, this might come out as a simple problem to some people, but I have been trying with so many combination just to get the proper syntax but with no avail.

Here is the deal. I am trying to simulate the following :

exten => 1234,n,MYSQL(Query resultid ${connid} UPDATE test SET IP = WHERE id = 1)

by writing an AGI in .c which will simply print out the following string:

exec MYSQL “Query resultid ${connid} ${query-string}”

to the CLI and ends it with /n. ${query-string} is “UPDATE test SET IP = WHERE id = 1”.

This should execute the application Mysql() with option “Query resultid ${connid} ${query-string}” in asterisk CLI, but I kept getting the following error message:

-- Executing [1234@check-accnt:1] AGI("SIP/support1-08758fa8", "updateip.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/updateip.agi
-- AGI Script Executing Application: (MYSQL) Options: (Query resultid ${connid} ${query-string})

[Jul 16 19:03:14] WARNING[26630]: app_addon_sql_mysql.c:288 aMYSQL_query: aMYSQL_query: missing some arguments
– AGI Script updateip.agi completed, returning 0

Which says that I do not have enough arguement passed. Im pretty much stumped after trying out for hours :blush: , so I am hoping someone knowledgable in AGI and Mysql() can point out my mistake :smiley: pleasee…

An update.

After doing some modification to app_addon_sql_mysql.c for debugging purposes, I found out that the problem wast that I used the syntax wrongly or that I have missing arguement.

By doing

exec MYSQL “Query resultid ${connid} ${query-string}”

${connid} and ${query-string} do not get automatically passed into the AGI, causing ${connid} to be always 0, thus causing the error message "aMYSQL_query: missing some arguments ".

For those who encountered the same problem, the way to do this is to actually use “GET VARIABLE connid” first to retrieve the value, then substitute the ${connid} and ${query-string} with their respective retrieved value.

Fortunately, the resultid does get automatically passed to asterisk, so no special step required (eg. in asterisk you can immediatelly used ${resultid} to get the result from the above execution).

Well, hope that helps.