2.2 Connection management
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog ODBC Interface
        • The ODBC layer
          • Connection management
            • odbc_connect/3
            • odbc_driver_connect/3
            • odbc_disconnect/1
            • odbc_current_connection/2
            • odbc_set_connection/2
            • odbc_get_connection/2
            • odbc_data_source/2
Availability::- use_module(library(odbc)).(can be autoloaded)
odbc_set_connection(+Connection, +Option)
Set options on an existing connection. All options defined here may also be specified with odbc_connect/2 in the option-list. Defined options are:
access_mode(Mode)
If read, tell the driver we only access the database in read mode. If update (default), tell the driver we may execute update commands.
auto_commit(bool)
If true (default), each update statement is committed immediately. If false, an update statement starts a transaction that can be committed or rolled-back. See section 2.4 for details on transaction management.
cursor_type(CursorType)
I haven't found a good description of what this does, but setting it to dynamic makes it possible to have multiple active statements on the same connection with Microsoft SQL server. Other values are static, forwards_only and keyset_driven.
encoding(+Encoding)
Define the encoding used to communicate to the driver. Defined values are given below. The default on MS-Windows is unicode while on other platforms it is utf8. Below, the *A() functions refer to the‘ansi' ODBC functions that exchange bytes and the *W() functions refer to the‘unicode' ODBC functions that exchange UCS-2 characters.
iso_latin_1
Communicate using the *A() functions and pass bytes untranslated.
locale
Communicate using the *A() functions and translated between Prolog Unicode characters and their (possibly) multibyte representation in the current locale.
utf8
Communicate using the *A() functions and translated between Prolog Unicode characters and their UTF-8 encoding.
unicode
Communicate using the *W() functions.
silent(Bool)
If true (default false), statements returning SQL_SUCCESS_WITH_INFO succeed without printing the info. See also section 2.8.1.
null(NullSpecifier)
Defines how the SQL constant NULL is represented. Without specification, the default is the atom $null$. NullSpecifier is an arbitrary Prolog term, though the implementation is optimised for using an unbound variable, atom and functor with one unbound variable. The representation null(_) is a commonly used alternative.

The specified default holds for all statements executed on this connection. Changing the connection default does not affect already prepared or running statements. The null-value can also be specified at the statement level. See the option list of odbc_query/4.

wide_column_threshold(+Length)
If the width of a column exceeds Length, use the API SQLGetData() to get the value incrementally rather than using a (large) buffer allocated with the statement. The default is to use this alternate interface for columns larger than 1024 bytes. There are two cases for using this option. In time critical applications with wide columns it may provide better performance at the cost of a higher memory usage and to work around bugs in SQLGetData(). The latter applies to Microsoft SQL Server fetching the definition of a view.