Function ODBC_ not registered

I have used ODBC successfully in the past, but now it is refusing to cooperate for some reason.


[phonevm] dsn => asterisk-connector readsql=SELECT mailbox from extension where extension='${ARG1}'


[asterisk-connector] driver = MySQL Database = dbname Server = localhost Socket = /var/lib/mysql/mysql.sock User = dbuser Password = dbpass


exten => 2988,1,Set(CALLERID(num)=121)
exten => 2988,n,set(ODBC_phonevm(${CALLERID(num)})=vmnumber)
exten => 2988,n,noop(--${vmnumber}--)


    -- Executing [s@main-ivr:1] Answer("SIP/gw1-00000002", "") in new stack
    -- Executing [s@main-ivr:2] Wait("SIP/gw1-00000002", "1") in new stack
    -- Executing [s@main-ivr:3] Set("SIP/gw1-00000002", "closed=") in new stack
    -- Executing [s@main-ivr:4] GotoIf("SIP/gw1-00000002", "0?closed-message,s,1") in new stack
    -- Executing [s@main-ivr:5] BackGround("SIP/gw1-00000002", "en/custom/main_night") in new stack
    -- <SIP/gw1-00000002> Playing 'en/custom/main_night.slin' (language 'en')
  == CDR updated on SIP/gw1-00000002
    -- Executing [2988@main-ivr:1] Set("SIP/gw1-00000002", "CALLERID(num)=121") in new stack
    -- Executing [2988@main-ivr:2] Set("SIP/gw1-00000002", "ODBC_phonevm(121)=vmnumber") in new stack
[Oct  8 01:29:30] ERROR[28546]: pbx.c:3732 ast_func_write: Function ODBC_phonevm not registered
    -- Executing [2988@main-ivr:3] NoOp("SIP/gw1-00000002", "----") in new stack
    -- Auto fallthrough, channel 'SIP/gw1-00000002' status is 'UNKNOWN'
[Oct  8 01:29:30] ERROR[28546]: cdr_odbc.c:148 odbc_log: Unable to retrieve database handle.  CDR failed.

Does anyone have any idea how to compel odbc to work as it should?


If Your conf-Files are quoted correctly, than there is really something wrong:

ODBC_-Functions (like phonevm) have to be defined in func_odbc.conf instead of cdr_odbc.conf.

a Set-Operation on a ODBC-Function implies that the function offers a writesql to set the values in the database.

In order to work successfull with odbc in Asterisk the System-side odbc.ini is not enough, You need to configure res_odbc.conf as well as Asterisk uses this file internally to connect via odbc.ini-declarations to the database.

Your extensions.conf is quite confusing to me: I don’t know what You’re trying to achieve. If You’d like to allocate the value of CALLERID(num) to vmnumber Your statement is completely wrong.

And these are only the first Ideas when looking for some seconds at Your post …