The ODBC interface deals with a single ODBC environment with multiple simultaneous connections. The predicates in this section deal with connection management.
alias
option is used. In addition to the options below, options applicable to
odbc_set_connection/2
may be provided.
user(User)
.once
(default if an alias
is provided), a second call to open the same DSN simply
returns the existing connection. If multiple
(default if
there is no alias name), a second connection to the same data-source is
opened.true
, use Microsoft SQL server 2005 mars mode.
This is support for multiple concurrent statements on a connection
without requiring the dynamic cursor (which incurs an astounding 20-50x
slowdown of query execution!!). MARS is a new feature in SQL2k5
apparently, and only works if you use the native driver. For the
non-native driver, specifying that it is enabled will have absolutely no
effect.'3.0'
.
The other supported value is '2.0'
.
The following example connects to the WordNet1An
SQL version of WordNet is available from http://wordnet2sql.infocity.cjb.net/
[1] database, using
the connection alias wordnet
and opening the connection
only once:
open_wordnet :- odbc_connect('WordNet', _, [ user(jan), password(xxx), alias(wordnet), open(once) ]).
user
and
password
.
Whenever possible, applications should use odbc_connect/3. If you need this predicate, please check the documentation for SQLDriverConnect() and the documentation of your driver.bugFacilities to deal with prompted completion of the driver options are not yet implemented.
read
, tell the driver we only access the database in
read mode. If update
(default), tell the driver we may
execute update commands.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.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
.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.
true
(default false
), statements returning
SQL_SUCCESS_WITH_INFO
succeed without printing the info.
See also section 2.8.1.$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.
Name(Value)
. If Property
is unbound all defined properties are enumerated on backtracking.
Currently the following properties are defined.
cursor_type
to dynamic
. See odbc_set_connection/2.