ODBC function

Freepbx 17.I am using ODBC to write some data to a Database(US_CIS2QUE and table is US_Customer )

freepbx user has the grant to insert to this database.

GRANT SELECT, INSERT, UPDATE ON US_CIS2QUE.* TO freepbxuser@localhost

func_odbc.conf :
[US_ADDCUSTOMER]
prefix=ODBC
dsn=US_CIS2QUE
mode=write
writehandle=US_CIS2QUE
readsql=SELECT cust_name,queue_no,queue_name FROM US_Customer WHERE cust_no=‘${SQL_ESC(${ARG1})}’
writesql=INSERT INTO US_Customer SET cust_no=‘${SQL_ESC(${ARG1})}’, cust_name=‘${SQL_ESC(${VAL1})}’, queue_no=‘${SQL_ESC(${VAL2})}’, queue_name=‘${SQL_ESC(${VAL3})}’, caller_id=‘${SQL_ESC(${ARG5})}’;

readsql = SELECT ‘OK’

odbc.ini

[US_CISCustInfo]
Description=Connect to US CISCustInfo US_CIS2QUE
driver=MySQL
server=localhost
database=US_CIS2QUE
Port=3306
Socket=
option=3

res_odbc_custom.conf

[US_CIS2QUE]
enabled => yes
dsn => US_CISCustInfo
username=> freepbxuser
password=> xxxxxxxxxx
pooling => yes
limit => 1
pre-connect => yes
autocommit => yes

And I call it from custom dial plan :

same => n,Set(RESULT=${ODBC_US_ADDCUSTOMER(${Cust_no},${Cust_name},${Queue_no},${Queue_name},${CALLERID(num)})})

In asterisk log I see RESULT is OK but data is not added to the database.

If I add it manually I can see data and if I update func_odbc to :
writesql = INSERT INTO US_Customer SET cust_no=‘100401’, cust_name=‘TEST CUSTOMER’, queue_no=‘99900001’, queue_name=‘Test Queue’, caller_id='764764

Same result. I dont see it in DB. Read is working. Write is not. Any idea why?

And this is odbc show

ODBC DSN Settings

Name: US_CIS2QUE
DSN: US_CISCustInfo
Number of active connections: 1 (out of 1)
Logging: Disabled

For reference for anyone in the future this was posted on the Asterisk forum and I answered it there:

1 Like

Thank you, its working now. I updated the other post on Asterisk forum.

1 Like

Thanks for updating this forum – linking to the source of the answer from wherever the question is asked helps the next user with this issue find it quickly via web search, which, potentially, can save you time in the future, because now your contemporary can go on to asking and/or solving additional things, making both FreePBX and Asterisk better overall. However, in the future, it is advisable not to cross-post the same question in multiple places and then leave it up to the mods to make the connection. :cowboy_hat_face:

I understand, but I did not get reply here, I posted it on Asterisk Forum two days later: :slight_smile:

Like I said above, how it’s fixed is shared on asterisk forum.
Thanks.