ODBC_CONNECT Function
Connect to an ODBC compliant data source.
Usage
connect_handle = ODBC_CONNECT(env_handle, dsn[, login])
Input Parameters
env_handle—An ODBC environment handle, as returned by ODBC_INIT.
dsn—String identifying a data source name (DSN).
login—A user name/password string if needed for given DSN.
Returned Value
connect_handle—An ODBC connection handle, used to identify this data source connection in other function calls. If the function fails, –1 is returned.
Keywords
Auto_commit—An integer value that specifies whether to use autocommit or manual-mode.
Manual commit mode (Auto_commit = 0)—In this mode users must explicitly use the ODBC_COMMIT function to commit any changes.
Autocommit mode (Auto_commit = 1)—In this mode users do not have to use the ODBC_COMMIT function. All changes are committed right after the SQL statement is executed.
Discussion
A DSN (data source name) is a logical entity defining a data source under ODBC. The end user creates DSNs via the ODBC Administrator.
These entities are machine-specific rather than user specific. System DSN attributes vary from driver to driver but contain, at minimum, entries identifying the physical location of the data, the ODBC driver associated with that data, a description field, and a name field.
It is the name field that will be passed to ODBC_CONNECT. If that driver for the system DSN supports login strings, the login parameter will be used to establish the connection, overriding the default login string if established for that DSN.
Multiple connections may be open at one time. Multiple connections to the same DSN may be established if supported by the driver.
Example 1
This example shows the default connection, where the DSN is ORACLE
.
oracle_id = ODBC_CONNECT(env_handle, 'ORACLE')
Example 2
This example shows the default connection, where the DSN is ORACLE
, and the username and password are given in the login string.
oracle_id = ODBC_CONNECT(env_handle, 'ORACLE','scott/tiger')