ODBC Connection


I am wanting to look up a MySQL database as part of my dial plan. I have got the database referenced by Asterisk…

odbc show

ODBC DSN Settings

  Name:   davos
  DSN:    MySQL-davos
    Last connection attempt: 1970-01-01 12:00:00
    Number of active connections: 1 (out of 1)

  Name:   asteriskcdrdb
  DSN:    MySQL-asteriskcdrdb
    Last connection attempt: 1970-01-01 12:00:00
    Number of active connections: 1 (out of 1)

However, everything I find says I need to put the query into func_odbc.conf file, this fine didnt exist; so I created it… but I’m not sure if it is actually used:

readsql=select * from tblevent where restoretime > NOW();

Ive referenced this in my dial plan:

exten => s,1(hastings),NoOp(Test: Hastings)
exten => s,n,set(resultset=${ODBC_SQL()})

However this

[2018-05-09 07:52:58] ERROR[13892][C-0000000c]: pbx_functions.c:608 ast_func_read: Function ODBC_SQL not registered

Any ideas what I’m missing here?

Not certain (it’s been a really long time since I messed with the ODBC interface, but I think your SQL entry in the config file should match whatever you are querying in the context.

Connect to asterisk (using “asterisk -vr”) and see what help you can get from the CLI. IIRC, there are ODBC commands available in the “Help” functions there.

Thanks for the reply… I’ve tried both ways now… same result :frowning:

Did you read though this?

Maybe there is a missing Asterisk Module?

If you haven’t yet, it might be worth asking the Asterisk forum.

1 Like

Thanks. From what I can make out everything I need is there; but still havent nailed it.


Are you passing the “Test the ODBC Data Source Name connection” section with an expected result?

Yes, no issues with that part

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.