Having configured odbcinst.ini thusly:
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.1
UsageCount=1
DebugLogging=true
And odbc.ini:
[CW-ReportingODBC]
Description=Reporting DB
Driver=ODBC Driver 17 for SQL Server
Server=host,port
and res_odbc_custom.conf:
[CW-ReportingA]
enabled=>yes
dsn=>CW-ReportingODBC
pre-connect=>yes
max_connections=>5
username=>un
password=>pwd
database=>db
and func_odbc.conf:
[CW-Reporting]
dsn=CW-ReportingA
readsql=${ARG1}
And verifying that I can connect with isql, and get a result (here, I look up Project 225 from our CRM, and return the Manager’s extension):
SQL> use db select PhoneNbr_Ext from v_rpt_member mem inner join v_rpt_projectheader proj on proj.Project_Manager = mem.Member_ID where proj.PM_Project_RecID = 225
[01000][Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Changed database context to ‘db’.
[ISQL]INFO: SQLExecute returned SQL_SUCCESS_WITH_INFO
±------------+
| PhoneNbr_Ext|
±------------+
| 114 |
±------------+
SQLRowCount returns 0
1 rows fetched
When I use the function in dynamic routes, the function fails to return results (from the log):
func_odbc.c: Returned 0 columns [use db select PhoneNbr_Ext from v_rpt_member mem inner join v_rpt_projectheader proj on proj.Project_Manager = mem.Member_ID where proj.PM_Project_RecID = 225]
I’ve tested this against another MSSQL DB, with similar results, and I’ve tested against a MySQL DB with some test data, and it works fine with MySQL. I have also tested with freetds odbc driver - no difference.
Does anyone have any experience with func_odbc and MSSQL, or suggestions as to where to go from here?