Asterisk func_odbc ODBCROWS function

Hi guys, I have my func_odbc.conf

[INFO]
prefix = USER
dsn = server
readsql = SELECT ${ARG1} FROM user WHERE phone=’${ARG2}’

And also my extensions.conf

[test]
exten => _Z.,1,NoOp()
same => n, Playback(/var/lib/asterisk/sounds/en/system-processing)
same => n,Set(__phone=${DID_INFO(phone,${EXTEN})})
same => n,Set(__mode=${DID_INFO(mode,${EXTEN})})
same => n,GotoIf($[${ODBCROWS} < 0]?cancel:modecheck)
same => n(modecheck),GotoIf($["${__mode}" = “DIRECT-DIALING”]?continue,directdialing,1:continue,pindialing,1)
same => n(cancel),Playback(/var/lib/asterisk/sounds/en/invalid-did-destination)
same => n,Hangup()

But I am getting this error in the console

[Aug 14 03:17:47] ERROR[3662][C-00003093]: pbx_functions.c:593 ast_func_read: Function USER_INFO not registered
[Aug 14 03:17:47] ERROR[3662][C-00003093]: pbx_functions.c:593 ast_func_read: Function USER_INFO not registered
[Aug 14 03:17:47] WARNING[3662][C-00003093]: ast_expr2.fl:470 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected ‘<’, expecting $end; Input:
< 0
^

Please what am I doing wrong?

This warning

[Aug 14 03:17:47] WARNING[3662][C-00003093]: ast_expr2.fl:470 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected ‘<’, expecting $end; Input:

is cuased by this

related to the :

[Aug 14 03:17:47] ERROR[3662][C-00003093]: pbx_functions.c:593 ast_func_read: Function USER_INFO not registered

Make sure the dns=server exist on res_odbc.conf file also the /etc/odbc.ini has been configured properly

Yes, it has. And also when I tried to show the functions I have created in func_odbc.conf, it says 0 matching custom functions.

I realized I also get the error cannot registered function error as well

You can verify if the custom function exist on your system core show functions like INFO If there is no match you will need to review the configuration files listed above

I run the command but I saw 3 functions that seems like a SYSINFO and 2 others like VM_INFO

And I have my function to be INFO as well, do you think it could be name conflicting

try core show functions like USER_INFO

It returns 0 matching custom functions installed.I tried to check module show like func_odbc.so but it is not loaded, you think that could be the cause

check the configuration on the file /etc/asterisk/func_odbc.conf

This is what I have

[INFO]
prefix = USER
dsn = server
readsql = SELECT ${ARG1} FROM USER WHERE phone=’${ARG2}’

[COUNT]
dsn=server
prefix=ROWS
readsql=SELECT IF(COUNT(1)>0, 1, 0) FROM user WHERE phone=’${ARG1}’

[COUNT]
dsn=server
prefix=PIN
readsql=SELECT IF(COUNT(1)>0, 1, 0) FROM user WHERE pin =’${ARG1}’ AND phone = ‘${ARG2}’

[INFO]
prefix = PIN
dsn = server
readsql = SELECT pin FROM USER WHERE pin=’${ARG1}’ AND phone = ‘${ARG2}’

try the command module load func_odbc.so

Yes I did that but it returns

Unable to load module func_odbc.so
Command ‘module load func_odbc.so’ failed.

but when I check it in /usr/lib/asterisk/modules/
I saw it there. So I dont know why Asterisk is not seeing it

I think you missed something during the Asterisk installation

You think I should restart Asterisk installation, to see if it will load the module

That could be an option make sure you install all the necessary packages in order the odbc works

http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html/asterisk-book.html#installing_configuring_odbc

When I run odbc show

It returns the system properies such as

name
dsn
date

and does it says Connected: Yes ?

In order you can use the odbc func you need to make sure the asterisk odbc connection is properly configured, also your system is complaining about the sql statement, at this point I just have 1 of 2 suggestion :

  1. recopile asterisk and make sure odbc is sucessfully installed

  2. check your existing configuration files and try to load the odbc modules

I just could not solve this, I dont know how func_odbc module is not working while the res_odbc is working

When I check the directory I couldn’t find the library

/usr/lib/libmyodbc3.so

In the /etc/odbcinst.ini file

I checked and no library libmyodbc3 is there