ODBC Driver Guide

Previous Topic

Next Topic

Unix/Linux ODBC Managers

Rather than linking directly with the c-treeACE SQL direct link ODBC driver, an application may link with a generic ODBC manager library, which loads the proper ODBC driver at runtime based on a requested DSN. This is the standard ODBC behavior on MS Windows. Unix platforms support various driver managers. One of the most common managers is the open source unixODBC library. For details on other proprietary Unix managers you are referred to their specific documentation.

To configure the unixODBC environment set the ODBCINI environment variable to refer to an .ini file (for example, odbc.ini) with your DSN information in your application environment. If ODBCINI is not set or unable to be opened, the driver will search $HOME/.odbc.ini for connection information.

The following example shows the ODBCINI setting for path /usr/local/unixODBC/etc/:


setenv ODBCINI /usr/local/unixODBC/etc/odbc.ini

Remember to set LD_LIBRARY_PATH with the path of the unixODBC install.

Note: The example below shows the setting for the path /usr/local/unixODBC/lib and c-tree path /home/FairCom/linux.x64.64bit/lib/sql.odbc:

setenv LD_LIBRARY_PATH /usr/local/unixODBC/lib:/home/FairCom/linux.x64.64bit/lib/sql.odbc

Here are typical settings for the c-treeACE SQL Unix ODBC driver to connect to a default server configuration on the local machine.

Note: The example below assumes that c-treeACE is installed in /home/FairCom//linux.x64.64bit:


Driver = /home/FairCom/linux.x64.64bit/lib/sql.odbc/

Host = localhost

Database = ctreeSQL


Password = ADMIN

Service = 6597

Below is information specific to unixODBC. This may vary across installations.

When SQLConnect() is called, unixODBC looks in the location specific by $ODBCINI for a matching DSN, and loads the specified "Driver". The "Driver" value may refer directly to a shared object to load, or another key.

If it is not a shared object, then you need a reference to the "Driver" value wherever the driver manager looks. With unixODBC, it typically looks in /etc/odbcinst.ini.


Description = ODBC for ctreeSQL

Driver = home/FairCom/linux.x64.64bit/lib/sql.odbc/

With unixODBC, tracing can be enabled by adding the following to /etc/odbcinst.ini:


Trace = Yes

TraceFile = /tmp/mytrace.log

This will log all ODBC calls with their parameter values and the return values to the TracingFile.

c-treeACE SQL PHP Example using unixODBC





$isc = odbc_connect('fc','admin','ADMIN');

if($isc == FALSE)



echo "FAIL - odbc_connect\n";




echo "PASS - odbc_connect\n";


$test = odbc_exec($isc,"SELECT TOP 1 owner,tbl,creator from systables");

if($test == FALSE)



echo "FAIL - odbc_exec\n";




echo "PASS - odbc_exec\n";


$val = odbc_result_all($test);

if($val == FALSE)



echo "FAIL - odbc_result_all\n";