odbc_connect(+DSN,
-Connection, +Options)Create a new ODBC connection to data-source DSN and return a
handle to this connection in Connection. The connection
handle is either an opaque structure or an atom of the alias
option is used. In addition to the options below, options applicable to
odbc_set_connection/2
may be provided.
- user(User)
- Define the user-name for the connection. This option must be present if
the database uses authorization.
- password(Password)
- Provide a password for the connection. Normally used in combination with
user(User)
.
- alias(AliasName)
- Use AliasName as Connection identifier, making the
connection available as a global resource. A good choice is to use the DSN
as alias.
- open(OpenMode)
- If OpenMode is
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.
- mars(+Bool)
- If
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.
- connection_pool_mode(+Bool)
- Determines how a connection is chosen from a connection pool if
connection pooling is on. See odbc_set_option/1
for enabling pooling. Permitted values are’strict’(Only
connections that exactly match the connection options in the call and
the connection attributes set by the application are reused. This is the
default) and’relaxed’(Connections with matching connection
string keywords can be used. Keywords must match, but not all connection
attributes must match.)
- odbc_version(+Atom)
- Select the version of the ODBC connection. Default is
'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)
]).