System information

In some situations you may specify a connection where you only want to log calls from
a specific source, or to a specific destination. We can do this with filters:
[logging_for_device_0000FFFF0008]
connection=asterisk_mysql
table=cdr_for_0000FFFF0008
filter src => 0000FFFF0008
If you need to populate a certain column with information based on a section name,
you can set it statically with the static option, which you may utilize with the filter
option:
[mysql_connection]
connection=asterisk_mysql
table=cdr
[filtered_mysql_connection]
connection=asterisk_mysql
table=cdr
filter src => 0000FFFF0008
static "DoNotCharge" => accountcode
In the preceding example you will get duplicate records in the same
table, but all the information will be the same except for the popu-
lated accountcode column, so you should be able to filter it out using
SQL.
ODBC Voicemail
Asterisk enables you to store voicemail inside the database using the ODBC connector.
This is useful in a clustered environment where you want to abstract the voicemail data
from the local system so that multiple Asterisk boxes have access to the same data. Of
course, you have to take into consideration that you are centralizing a part of Asterisk,
and you need to take actions to protect that data, such as making regular backups and
possibly clustering the database backend using replication.
Asterisk stores each voicemail message inside a Binary Large Object (BLOB). When
retrieving the data, it pulls the information out of the BLOB and temporarily stores it
on the hard drive while it is being played back to the user. Asterisk then removes the
BLOB and the record from the database when the user deletes the voicemail. Many
databases, such as MySQL, contain native support for BLOBs, but as you’ll see, with
PostgreSQL a couple of extra steps are required to utilize this functionality that we’ll
explore in this section. When you’re done, you’ll be able to record, play back, and
delete voicemail data from the database just as if it were stored on the local hard drive.
378 | Chapter 16:Relational Database Integration