ODBC

From wiki.visual-prolog.com

Revision as of 14:56, 18 June 2009 by Elizabeth Safro (talk | contribs) (a grammar mistake fix)

Visual Prolog (Commercial Edition) has an ODBC package, which gives access to databases that have an ODBC driver. The distribution contains two ODBC examples (In IDE: Help->Install Examples...).

Here is a little background information about ODBC.

ODBC is an abstraction layer. (There are many abstraction layers in Windows, and the general principle is the same in all cases; It's a pattern).

The purpose of the layer is to provide uniform access to different databases.

Applications run on top of the layer. They access the layer through an Application Programming Interface (API).

Below the layer database vendors (and others) can hook-in ODBC drivers, through the Device Driver Interface (DDI).

The API/DDI pattern is an abstraction pattern that Microsoft uses in numerous contexts.

The SQL syntax you should use towards ODBC is defined by ODBC, so in principle there should be no differences in syntax: It is the responsibility of the device drivers to use this dialect of ODBC. The truth is a bit more complex, and you can find a more accurate description in Interoperability of SQL Statements.

In ODBC a parameter is "?" like in:

SELECT Name FROM Person WHERE Age > ?

Native Oracle SQL uses a different syntax for parameters, but Oracle ODBC drivers use the "?".

Microsoft has defined ODBC and developed MS SQL hand-in-hand, so not surprisingly, MS SQL follows the ODBC syntax very closely. MS Access is slightly less accurate, but in most work you will not feel any differences.

In any case the accuracy depends on the driver that you have. Most database vendors deliver ODBC drivers for their databases, but there are also third party companies that deliver ODBC drivers (e.g. DataDirect).

You can get Microsoft's ODBC drivers in the MDAC package.

Besides the obvious drivers Microsoft it also contains drivers for comma-separated text files and Excel.

The intention of this is not to use text files as a database, but to provide a simple way to read, write and otherwise manipulate comma separated text files.

The Excel driver has a similar purpose. But you must realize that the access is SQL oriented, not Excel oriented. So you can deal with date which is organised in a very special way in Excel, and thus not exploit the full features of Excel. And formulas and formatting is completely unknown in the ODBC access.

References