The interface of the Erlang ODBC application divided into four parts:
An ODBC serving process can be compared to an Erlang port. It allows you to make function calls, from Erlang, to an ODBC Driver (or in reality a Driver Manager, which talks to a Driver). The Driver communicates with the database, which it is built for. The serving process also plays the role of a server and will be referred to as the server in this text.
When you start ODBC you get a new server, which handles requests by passing them on to an ODBC Driver. Requests are handled sequentially and the server cannot be connected to more than one database at any time.
![]() |
An ODBC server can
only be started on a named node with a cookie (start Erlang with
one of the -name |
The server links to the process that starts it (the client). Should the client terminate, the server terminates too. The server is dedicated to the client process just like an Erlang port, but there are two important differences: an ODBC server accepts requests from any process (ports accept messages from the connected process only), and it does not send messages spontaneously (or deliver them from the ODBC Driver) -- the ODBC server is passive.
Using the Utility API is easy. Follow the steps below:
start_link/[2, 3]
.
erl_connect/[2, 3, 4, 5]
erl_executeStmt/[2, 3]
.
erl_disconnect/[1, 2]
.
At this point it is possible to connect to
another database by calling erl_connect/[2, 3, 4, 5]
again.
stop/[1, 2]
is called.
To be able to make full use of the Basic API it is necessary to be familiar with the ODBC standard. Here is a typical way to use it for a SELECT statement though:
sqlConnect/[4, 5]
.
sqlExecDirect/[2, 3]
sqlNumResultCols/[1, 2]
returns a value greater than zero.sql_describe_col/[4, 5]
.
columnRef/0
.
sqlBindCol/[3, 4]
.
sqlFetch/[1, 2]
.getData/[2, 3]
.
sqlCloseCursor/[1, 2]
.
sqlDisConnect/[1, 2]
.
You may use the Basic API and the Utility API intermittently, but remember that certain operations performed in the Basic API (like setting different attributes defined by the ODBC standard) may affect the behaviour of the Utility API.
When to use which API? The Utility API can be used when none of the following is true: