Getting Funky with func_odbc: Hot-Desking
The func_odbc dialplan
function is arguably the coolest and most powerful dialplan
function in Asterisk. It allows you to create and use fairly simple
dialplan functions that retrieve and use information from databases
directly in the dialplan. There are all kinds of ways in which this
might be used, such as managing users or allowing sharing of dynamic
information within a clustered set of Asterisk machines.
What func_odbc allows you to do
is define SQL queries to which you assign function names. In effect, you are
creating custom functions that obtain their results by executing queries
against a database. The func_odbc.conf file is where you specify the relationship between the function
names you create and the SQL statements you wish them to perform. By
referring to the named function in the dialplan, you can retrieve and
update values in the database.
Tip
While using an external script to interact with a database (from which a flat file is created that Asterisk would read) has advantages (if the database went down, your system would continue to function and the script would simply not update any files until connectivity to the database was restored), a major disadvantage is that any changes you make to a user are not available until you run the update script. This is probably not a big issue on small systems, but on large systems, waiting for changes to take effect can cause issues, such as pausing a live call while a large file is loaded ...