I am using this string for a database lookup based on the number dialed, the idea being to pull an “account code” from the DB and run a GoTo in the dialplan based on the returned result of the lookup.
same => Set(ACCOUNTCODE=${ABC_ACCT(${EXTEN})})
same => n,Goto(${ACCOUNTCODE},${EXTEN},)
after making changes in func_odbc, when I run module reload func_odbc.so I get an error ONLY for the variable/query I have created: Cannot initialize query ACCT. When I test the query in my SQL engine it returns as expected. what I am doing wrong in func_odbc that the variable/query lookup is not working as I intend?
There are other variables that use ABC prefix, I dont think that would create a conflict, but is it?
[ACCT]
prefix=ABC
;dsn=asterisk
dsn=local-db
SELECT accountcode FROM table WHERE field = '${ARG1}'
;readsql=SELECT accountcode FROM some_other_table WHERE number = '${ARG1}'
ah, yeah thanks. that cleared up the cannot initialize query issue. didnt even realize I was missing the readsql bit to start the query. thank you
as for what the database says, I am not sure what youre asking. the query returns the data I am looking for when I run it in the DB. and also now when I run odbc read ABC_ACCT it seems to test the query, which it wasn’t before
yeah that seems to be the case. I dont see anything in the logging.
with the query fixed though…any idea why the lookup would be failing? Here is the returned output from the CLI
-- Executing [xxxxxxxxxx@messages-in:1] NoOp("Message/ast_msg_queue", "MODIFIED receiving dialplan invoked") in new stack
-- Executing [xxxxxxxxxx@messages-in:2] Goto("Message/ast_msg_queue", ",xxxxxxxxxx,") in new stack
so it looks like I am in the dialplan where I would expect to be to handle an incoming message, but my Set(ACCOUNTCODE=${ABC_ACCT(${EXTEN})}) lookup doesnt return the accountcode I need to execute the GoTo…any ideas?
I can’t see what you are trying to do. You’d need to post the relevant dialplan and possibly the console output for “verbose” >= 3. You should also describe which database you are using. Usually you should be able to log the sql statements, just in case.