Programming with SQL Relay using ODBC

The SQL Relay distribution provides an experimental ODBC driver. The driver is incomplete, may only be used with iODBC or unixODBC, and is NOT supported on Windows, but may be experimented with and may be useful for some simple programs.

With iODBC or unixODBC, you can create a DSN for SQL Relay just like you would for any other database by editing /etc/odbc.ini and adding an entry like the following:

>     [sqlrtest]
>     Driver=/usr/local/firstworks/lib/libsqlrodbc.so
>     SERVER=localhost
>     PORT=8006
>     DATABASE=testdb
>     USER=testuser
>     PASSWORD=testpass

Now you can use the isql command line utility that comes with iODBC or unixODBC to access the database through SQL Relay as follows:

> isql sqlrtest

Here is a sample session:

>     [mused@localhost /home/mused]$ isql sqlrtest
>     +---------------------------------------+
>     | Connected!                            |
>     |                                       |
>     | sql-statement                         |
>     | help [tablename]                      |
>     | quit                                  |
>     |                                       |
>     +---------------------------------------+
>     SQL> create table test (col1 varchar(20));
>     SQLRowCount returns 0
>     SQL> insert into test values ('hello');
>     SQLRowCount returns 1
>     SQL> insert into test values ('bye');
>     SQLRowCount returns 1
>     SQL> select * from test;
>     +-----------+
>     | col1      |
>     +-----------+
>     | hello     |
>     | bye       |
>     +-----------+
>     SQLRowCount returns 0
>     2 rows fetched
>     SQL> quit;

Similarly, any program that uses ODBC can be configured to use SQL Relay via ODBC by setting its DSN to the SQL Relay DSN defined in /etc/odbc.ini.

Developing applications which use ODBC is beyond the scope if this document but many examples and tutorials may be found on the web.