10.14.2.1 Example 1

The first example just verifies that ODBC is working and that some ODBC drivers have been configured in the ODBC Driver Manager.

     :- use_module(library(odbc)).
     
     example1 :-
         odbc_env_open(EnvHandle),
         odbc_list_DSN(EnvHandle, DSNs),
         odbc_env_close(EnvHandle),
         format('The known DSNs are: ~q~n', [DSNs]).

You begin by opening an environment. This is a handle which can be used for various calls to the ODBC Driver Manager (DM). You then ask the DM about the data sources, i.e. databases, it knows about. If this list is empty you need to install and configure the ODBC drivers appropriate for the database management system that you intend to use.


Send feedback on this subject.