Previous: , Up: lib-odbc   [Contents][Index]


10.26.5 Predicates

odbc_env_open(-EnvHandle)

Opens an ODBC environment. Throws an exception if the environment could not be opened.

odbc_db_open(+Dbname,+EnvHandle,-ConnectionHandle)

Opens a database with the name Dbname. The database cannot require a username and a password. ConnectionHandle is an opaque handle for accessing the database.

odbc_db_open(+Dbname,+EnvHandle,+Options,-ConnectionHandle)

Opens a database with the name Dbname. Options should be a list of zero or more of:

username(+Username)

The username for connecting to the database. The default is ''.

password(+Password)

The password for connection to the database. The default is ''.

login_timeout(+Timeout)

The number of seconds to wait for a login request to complete. If 0 is used, the login attempt will wait indefinitely. The default is driver-dependent.

connection_timeout(+Timeout)

The number of seconds to wait for any request on the connection to complete. If the Timeout value is 0 (the default), there is no timeout.

raw(+ConnectionOptions)

ConnectionOptions should be a list of atoms. They are passed, terminated by ;, as extra options when opening the database.

ConnectionHandle is an opaque handle for accessing the database.

odbc_db_open(+Dbname,+EnvHandle,+Options,-ConnectionHandle,-ConnectionString)

Like odbc_db_open/4 but also returns the completed connection string returned by the ODBC driver.

odbc_query_open(+ConnectionHandle, -StatementHandle)

Creates a new database query. ConnectionHandle is a handle previously allocated with odbc_db_open/[3,4,5].

odbc_list_DSN(+EnvHandle,-DSNs)

EnvHandle is an opaque database handle. DSNs is unified with a list of all DSNs (Data Source Names). The list elements are X-Y where X is the DSN and Y its description.

odbc_list_data_types(+StatementHandle, +TableDesc, -DataTypes)

Makes a list of the datatypes in a table. StatementHandle is a handle previously allocated with odbc_query_open/2. TableDesc is a description of the table and its columns of the form tablename(columnname1, columnname2, ..., columnnameN), or of the form [tablename, columnname1, columnname2, ..., columnnameN] (the latter form is useful if the table has more than 255 columns). DataTypes is unified with a list of the corresponding datatypes, i.e. on the form [datatype1, datatype2, ... datatypeN].

odbc_current_table(+ConnectionHandle, ?TableName)   since release 4.2

Enumerate the proper tables in the database, i.e. tables with attribute 'TABLE_TYPE'("TABLE").

ConnectionHandle is a handle previously allocated with odbc_db_open/[3,4,5]. TableName is the name, as an atom, of the table.

Note that odbc_current_table/2 may exit nondeterminately even if all arguments are instantiated when it is called.

odbc_current_table(+ConnectionHandle, ?TableName, ?Attribute)   since release 4.2

Enumerate database tables and their attributes.

ConnectionHandle is a handle previously allocated with odbc_db_open/[3,4,5]. TableName is the name, as an atom, of the table. Attribute is an attribute of the table.

There are two kinds of attributes, derived attributes and raw attributes.

The derived attributes are translations of raw attributes and other information and are in a format that is directly useful. There is currently only one derived attribute,

arity(Value)

The number of columns in the table, as an integer.

This attribute is always present.

the set of derived attributes may be extended in the future.

The raw attributes correspond direcly to the (non-null) values returned from the ODBC function SQLTables() and are returned as is, wrapped in a functor with the same name as the attribute, e.g. 'TABLE_CAT'("foo") would be returned for a table in the catalog "foo". Note that the names of the raw attributes are in all uppercase so you need to surround them with single quotes to prevent their name from being parsed as a variable. Some of the raw attributes are,

'TABLE_CAT'(Value)

Catalog name, as a code list. This attribute corresponds to the TABLE_CAT column, called TABLE_QUALIFIER in ODBC 2.0, as returned from the ODBC function SQLTables().

'TABLE_TYPE'(Value)

Table type, as a code list. This attribute corresponds to the TABLE_TYPE column, as returned from the ODBC function SQLTables(). The standard table types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", and "SYNONYM", but there can be data-source-specific types as well.

This attribute is always present.

'REMARKS'(Value)

Table descriptive text, as a code list. This attribute corresponds to the REMARKS column, as returned from the ODBC function SQLTables().

see the ODBC documentation for SQLTables() for the full list of raw attributes and their meaning.

Note that odbc_current_table/3 may exit nondeterminately even if one of more arguments are instantiated when it is called.

odbc_table_column(+ConnectionHandle, ?TableName, ?ColumnName)   since release 4.2

Enumerate database table columns.

ConnectionHandle is a handle previously allocated with odbc_db_open/[3,4,5]. TableName is the name, as an atom, of the table. ColumnName is the name, as an atom, of the table.

odbc_table_column(+ConnectionHandle, ?TableName, ?ColumnName, ?Attribute)   since release 4.2

Enumerate database table columns and their attributes.

ConnectionHandle is a handle previously allocated with odbc_db_open/[3,4,5]. TableName is the name, as an atom, of the table. ColumnName is the name, as an atom, of the table. Attribute is an attribute of the table.

There are two kinds of attributes, derived attributes and raw attributes.

The derived attributes are translations of raw attributes and other information and are in a format that is directly useful. There is currently only one derived attribute,

nullable(Value)

true if the column is definitely nullable, or false if the column is definitely not nullable. The value is derived from the raw attributes NULLABLE and IS_NULLABLE, see the documentation for SQLColumns() for details.

This attribute is not present if it can not be determined whether the column is nullable.

the set of derived attributes may be extended in the future.

The raw attributes correspond direcly to the (non-null) values returned from the ODBC function SQLColumns() and are returned as is, wrapped in a functor with the same name as the attribute, e.g. 'TABLE_CAT'("foo") would be returned for a column in a table in the catalog "foo". Note that the names of the raw attributes are in all uppercase so you need to surround them with single quotes to prevent their name from being parsed as a variable. Some of the raw attributes are,

'REMARKS'(Value)

Column descriptive text, as a code list. This attribute corresponds to the REMARKS column, as returned from the ODBC function SQLColumns().

'ORDINAL_POSITION'(Value)

The ordinal position of the column in the table, starting at 1. This attribute corresponds to the ORDINAL_POSITION column, as returned from the ODBC function SQLColumns().

This attribute is always present.

See the ODBC documentation for SQLColumns() for the full list of raw attributes and their meaning.

Note that odbc_table_column/4 may exit nondeterminately even if one of more arguments are instantiated when it is called.

odbc_query_execute_sql(+StatementHandle, +SQLString, +ParamData, +ParamDataTypes, -ResultSet)

Executes an SQL query. StatementHandle is a handle previously allocated with odbc_query_open/2. SQLString is the SQL statement to be executed. The statement string may contain parameter markers. ParamData is a list of data to be bound to the parameter markers. ParamDataTypes is a list of data types corresponding to the ParamData list. ResultSet is bound to an opaque data structure describing the result of the query.

odbc_query_execute_sql(+StatementHandle, +SQLString, -ResultSet)

StatementHandle is a handle previously allocated with odbc_query_open/2. SQLString is the SQL statement to be executed. ResultSet is bound to an opaque data structure describing the result of the query.

odbc_sql_fetch(+ResultSet, -Row)

Fetch the next row from the result set. ResultSet is the result set from odbc_query_execute_sql/[3,5]. Row is unified with a non-empty list of data constituting a row in the result set, or with [] when there are no more rows. The elements in the Row are in the same order as in the corresponding query.

odbc_query_close(+Query)

Closes the query represented by Query, which can be either a result set, e.g. as returned from odbc_query_execute_sql/[3,5], or it can be a statement handle, as returned from odbc_query_open/2.

odbc_db_close(+ConnectionHandle)

Closes the connection to the database.

odbc_env_close(+EnvHandle)

Frees the environment handle.



Send feedback on this subject.