Asterisk 11.8.1: ast_odbc_direct_execute: SQL Execute error!

I’ve been reading a lot of forum (too Asterisk- The Definitive Guide, 4th Edition) but without success…
I thought to appeal for your help.

I have this system config:

/etc/odbcinst.ini
[MySQLAnsi]
Description = ODBC MySQL 5.3.4-1 Ansi
Driver = /usr/lib64/libmyodbc5a.so
UsageCount = 2

/etc/odbc.ini
[MySQL-connector]
Driver=MySQLAnsi
Server=192.168.0.20
Database=pippo
Port=3306
Option=3
User=root
Password=pwd
UsageCount=1
ReadOnly = No

test connection with isql works fine…

/etc/asterisk/res_odbc.conf
[ENV]
ODBCINI => /etc/odbc.ini
ODBCSYSINI => /etc

[MySQL-asterisk]
enabled => yes
dsn => MySQL-connector
username => root
password => pwd
pre-connect => yes
sanitysql => select 1
share_connections => yes
idlecheck => 3600
isolation => repeatable_read

/etc/asterisk/cdr_adaptive_odbc.conf
[MySQL-asterisk]
connection=MySQL-asterisk
table=tp_astcdr
alias start => calldate

/etc/asterisk/cdr_odbc.conf
[global]
dsn=MySQL-asterisk
loguniqueid=yes
dispositionstring=yes
table=tp_astcdr
usegmtime=no
hrtime=yes

Asterisk console:
[Aug 8 16:38:28] NOTICE[10068]: res_odbc.c:792 load_odbc_config: Adding ENV var: ODBCINI=/etc/odbc.ini
[Aug 8 16:38:28] NOTICE[10068]: res_odbc.c:792 load_odbc_config: Adding ENV var: ODBCSYSINI=/etc
[Aug 8 16:38:28] NOTICE[10068]: res_odbc.c:1527 odbc_obj_connect: Connecting MySQL-asterisk
[Aug 8 16:38:28] NOTICE[10068]: res_odbc.c:1559 odbc_obj_connect: res_odbc: Connected to MySQL-asterisk [MySQL-connector]
[Aug 8 16:38:28] NOTICE[10068]: res_odbc.c:919 load_odbc_config: Registered ODBC class ‘MySQL-asterisk’ dsn->[MySQL-connector]


[Aug 8 16:41:01] WARNING[10073][C-00000006]: res_odbc.c:608 ast_odbc_direct_execute: SQL Execute error! Verifying connection to MySQL-asterisk [MySQL-connector]…
[Aug 8 16:41:01] ERROR[10073][C-00000006]: cdr_odbc.c:162 odbc_log: CDR direct execute failed

Can someone help me?

Thank you
Luca

Are you sure you want to use cdr_odbc? It has a quirky and slightly old-ish schema, which might explain why the SQL statements are failing.

Generally, if you want to store CDRs in a database using ODBC, you should use cdr_adaptive_odbc as your CDR driver.

Thank you for your time mjordan, I don’t really have test this “route”… Are you already examples for me?

Luca

I referred you to cdr_adaptive_odbc because it is the supported ODBC CDR backend. cdr_odbc is extended support - but frankly should have been deprecated, given its quirks. If you want to run with cdr_odbc that’s your choice, but you should know that you are using an antiquated module that does not map to the CDR schemas delivered with Asterisk.

If you want to use the recommended module, you can see its sample configuration in cdr_adaptive_odbc.conf.sample, which should work directly with the CDR schemas delivered with Asterisk.

2 Likes

I have deactivated in menuselect cdr_odbc; recompiled. This solution works fine. Thanks