f90SQLGetInfo (SQLGetInfo)

 

Conformance

Version Introduced: ODBC 1.0

Standards Compliance: ISO 92

 

Summary

f90SQLGetInfo returns general information about the driver and data source associated with a connection.

 

Syntax

f90SQLGetInfo (ConnectionHandle, InfoType, InfoValue, iRet)

 

integer(SQLHDBC_KIND),intent(in):: ConnectionHandle
integer(SQLUSMALLINT_KIND),intent(in):: InfoType
{
integer(SQLUINTEGER_KIND),intent(in):: InfoValue |
integer(SQLUSMALLINT_KIND),intent(out):: InfoValue
}
integer(SQLRETURN_KIND),intent(out):: iRet

 

f90SQLGetInfo (ConnectionHandle, InfoType, InfoValue, InfoValueStringLength, iRet)

 

integer(SQLHDBC_KIND),intent(in):: ConnectionHandle
integer(SQLUSMALLINT_KIND),intent(in):: InfoType
character(len=*),intent(out):: InfoValue
integer(SQLSMALLINT_KIND):: InfoValueLength
integer(SQLRETURN_KIND),intent(out):: iRet

 

Arguments

ConnectionHandle [Input]

Connection handle.

InfoType [Input]

Type of information.

InfoValue [Output]

Buffer in which to return the information. Depending on the InfoType requested, the information returned will be one of the following: a null-terminated character string, an SQLUSMALLINT value, an SQLUINTEGER bitmask, an SQLUINTEGER flag, or a SQLUINTEGER binary value.

If the InfoType argument is SQL_DRIVER_HDESC or SQL_DRIVER_HSTMT, the InfoValue argument is both input and output. (See the SQL_DRIVER_HDESC or SQL_DRIVER_HSTMT descriptors later in this function description for more information.). In this case, f90SQLGetInfo must be called using the Pointer Format (See Appendix 2. Calling f90SQL subroutines using the Pointer Format)

InfoValueLength [Output]

Buffer in which to return the total number of bytes (excluding the null-termination character for character data) available to return in InfoValue.

For character data, if the number of bytes available to return is greater than or equal to Len(InfoValue), the information in InfoValue is truncated to Len(InfoValue) bytes minus the length of a null-termination character and is null-terminated by the driver.

iRet [Output]

SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.

Diagnostics

When f90SQLGetInfo returns either SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling f90SQLGetDiagRec with a HandleType of SQL_HANDLE_DBC and a Handle of ConnectionHandle. The following table lists the SQLSTATE values commonly returned by f90SQLGetInfo and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.

SQLSTATE Error Description
01000 General warning Driver-specific informational message. (Function returns SQL_SUCCESS_WITH_INFO.)
01004 String data, right truncated The buffer InfoValue was not large enough to return all of the requested information, so the information was truncated. The length of the requested information in its untruncated form is returned in InfoValueLength. (Function returns SQL_SUCCESS_WITH_INFO.)
08003 Connection does not exist (DM) The type of information requested in InfoType requires an open connection. Of the information types reserved by ODBC, only SQL_ODBC_VER can be returned without an open connection.
08S01 Communication link failure The communication link between the driver and the data source to which the driver was connected failed before the function completed processing.
HY000 General error An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by f90SQLGetDiagRec in the MessageText buffer describes the error and its cause.
HY001 Memory allocation error The driver was unable to allocate memory required to support execution or completion of the function.
HY013 Memory management error The function call could not be processed because the underlying memory objects could not be accessed, possibly because of low memory conditions.
HY024 Invalid attribute value (DM) The InfoType argument was SQL_DRIVER_HSTMT, and the value pointed to by InfoValuePtr was not a valid statement handle.

(DM) The InfoTypePtr argument was SQL_DRIVER_HDESC, and the value pointed to by InfoValue was not a valid descriptor handle.

HY090 Invalid string or buffer length (DM) The value specified for argument Len(InfoValue) was less than 0.

(DM) The value specified for Len(InfoValue) was an odd number, and InfoValue was of a Unicode data type.

HY096 Information type out of range The value specified for the argument InfoType was not valid for the version of ODBC supported by the driver.
HYC00 Optional field not implemented The value specified for the argument InfoType was a driver-specific value that is not supported by the driver.
HYT01 Connection timeout expired The connection timeout period expired before the data source responded to the request. The connection timeout period is set through f90SQLSetConnectAttr, SQL_ATTR_CONNECTION_TIMEOUT.
IM001 Driver does not support this function (DM) The driver corresponding to the ConnectionHandle does not support the function.

 

Comments

The currently defined information types are shown in Appendix 1; it is expected that more will be defined to take advantage of different data sources. f90SQLGetInfo performs no Unicode conversion or thunking for driver-defined InfoTypes. The format of the information returned in InfoValue depends on the InfoType requested. f90SQLGetInfo will return information in one of five different formats:

The format of each of the following information types is noted in the type's description. The application must cast the value returned in InfoValue accordingly. For an example of how an application could retrieve data from a SQLUINTEGER_KIND bitmask, see "Code Example."

A driver must return a value for each of the information types defined in the following tables. If an information type does not apply to the driver or data source, then the driver returns one of the following values:

Format of InfoValue Returned value
Character string ("Y" or "N") "N"
Character string (not "Y" or "N") Empty string
SQLUSMALLINT_KIND 0
SQLUINTEGER_KIND bitmask or SQLUINTEGER_KIND binary value 0

For example, if a data source does not support procedures, f90SQLGetInfo returns the following values for the values of InfoType that are related to procedures:

InfoType Returned value
SQL_PROCEDURES "N"
SQL_ACCESSIBLE_PROCEDURES "N"
SQL_MAX_PROCEDURE_NAME_LEN 0
SQL_PROCEDURE_TERM Empty string

f90SQLGetInfo returns SQLSTATE HY096 (Invalid argument value) for values of InfoType that are in the range of information types reserved for use by ODBC but are not defined by the version of ODBC supported by the driver. To determine what version of ODBC a driver conforms to, an application calls f90SQLGetInfo with the SQL_DRIVER_ODBC_VER information type. f90SQLGetInfo returns SQLSTATE HYC00 (Optional feature not implemented) for values of InfoType that are in the range of information types reserved for driver-specific use but are not supported by the driver.

All calls to f90SQLGetInfo require an open connection, except when the InfoType is SQL_ODBC_VER, which returns the version of the Driver Manager.

Information Types

This section lists the information types supported by f90SQLGetInfo. Information types are grouped categorically and listed alphabetically. Information types that were added or renamed for ODBC 3.0 are also listed.

Driver Information

The following values of the InfoType argument return information about the ODBC driver, such as the number of active statements, the data source name, and the interface standards compliance level.

SQL_ACTIVE_ENVIRONMENTSSQL_ASYNC_MODE SQL_INFO_SCHEMA_VIEWS
SQL_BATCH_ROW_COUNT SQL_KEYSET_CURSOR_ATTRIBUTES1
SQL_BATCH_SUPPORT SQL_KEYSET_CURSOR_ATTRIBUTES2
SQL_DATA_SOURCE_NAME SQL_MAX_ASYNC_CONCURRENT_STATEMENTS
SQL_DRIVER_HDBC SQL_MAX_CONCURRENT_ACTIVITIES
SQL_DRIVER_HDESC SQL_MAX_DRIVER_CONNECTIONS
SQL_DRIVER_HENV SQL_ODBC_INTERFACE_CONFORMANCE
SQL_DRIVER_HLIB SQL_ODBC_STANDARD_CLI_CONFORMANCE
SQL_DRIVER_HSTMT SQL_ODBC_VER
SQL_DRIVER_NAME SQL_PARAM_ARRAY_ROW_COUNTS
SQL_DRIVER_ODBC_VER SQL_PARAM_ARRAY_SELECTS
SQL_DRIVER_VER SQL_ROW_UPDATES
SQL_DYNAMIC_CURSOR_ATTRIBUTES1 SQL_SEARCH_PATTERN_ESCAPE
SQL_DYNAMIC_CURSOR_ATTRIBUTES2 SQL_SERVER_NAME
SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 SQL_STATIC_CURSOR_ATTRIBUTES1
SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 SQL_STATIC_CURSOR_ATTRIBUTES2
SQL_FILE_USAGE  

DBMS Product Information

The following values of the InfoType argument return information about the DBMS product, such as the DBMS name and version.

SQL_DATABASE_NAME SQL_DBMS_VER
SQL_DBMS_NAME  

Data Source Information

The following values of the InfoType argument return information about the data source, such as cursor characteristics and transaction capabilities.

SQL_ACCESSIBLE_PROCEDURES SQL_MULT_RESULT_SETS
SQL_ACCESSIBLE_TABLES SQL_MULTIPLE_ACTIVE_TXN
SQL_BOOKMARK_PERSISTENCE SQL_NEED_LONG_DATA_LEN
SQL_CATALOG_TERM SQL_NULL_COLLATION
SQL_COLLATION_SEQ SQL_PROCEDURE_TERM
SQL_CONCAT_NULL_BEHAVIOR SQL_SCHEMA_TERM
SQL_CURSOR_COMMIT_BEHAVIOR SQL_SCROLL_OPTIONS
SQL_CURSOR_ROLLBACK_BEHAVIOR SQL_TABLE_TERM
SQL_CURSOR_SENSITIVITY SQL_TXN_CAPABLE
SQL_DATA_SOURCE_READ_ONLY SQL_TXN_ISOLATION_OPTION
SQL_DEFAULT_TXN_ISOLATION SQL_USER_NAME
SQL_DESCRIBE_PARAMETER  

Supported SQL

The following values of the InfoType argument return information about the SQL statements supported by the data source. The SQL syntax of each feature described by these information types is the SQL92 syntax. These information types do not exhaustively describe the entire SQL92 grammar. Instead, they describe those parts of the grammar for which data sources commonly offer different levels of support. Specifically, most of the DDL statements in SQL92 are covered.

Applications should determine the general level of supported grammar from the SQL_SQL_CONFORMANCE information type and use the other information types to determine variations from the stated standards compliance level.

SQL_AGGREGATE_FUNCTIONS SQL_DROP_TABLE
SQL_ALTER_DOMAIN SQL_DROP_TRANSLATION
SQL_ALTER_SCHEMA SQL_DROP_VIEW
SQL_ALTER_TABLE SQL_EXPRESSIONS_IN_ORDERBY
SQL_ANSI_SQL_DATETIME_LITERALS SQL_GROUP_BY
SQL_CATALOG_LOCATION SQL_IDENTIFIER_CASE
SQL_CATALOG_NAME SQL_IDENTIFIER_QUOTE_CHAR
SQL_CATALOG_NAME_SEPARATOR SQL_INDEX_KEYWORDS
SQL_CATALOG_USAGE SQL_INSERT_STATEMENT
SQL_COLUMN_ALIAS SQL_INTEGRITY
SQL_CORRELATION_NAME SQL_KEYWORDS
SQL_CREATE_ASSERTION SQL_LIKE_ESCAPE_CLAUSE
SQL_CREATE_CHARACTER_SET SQL_NON_NULLABLE_COLUMNS
SQL_CREATE_COLLATION SQL_SQL_CONFORMANCE
SQL_CREATE_DOMAIN SQL_OJ_CAPABILITIES
SQL_CREATE_SCHEMA SQL_ORDER_BY_COLUMNS_IN_SELECT
SQL_CREATE_TABLE SQL_OUTER_JOINS
SQL_CREATE_TRANSLATION SQL_PROCEDURES
SQL_DDL_INDEX SQL_QUOTED_IDENTIFIER_CASE
SQL_DROP_ASSERTION SQL_SCHEMA_USAGE
SQL_DROP_CHARACTER_SET SQL_SPECIAL_CHARACTERS
SQL_DROP_COLLATION SQL_SUBQUERIES
SQL_DROP_DOMAIN SQL_UNION
SQL_DROP_SCHEMA  

SQL Limits

The following values of the InfoType argument return information about the limits applied to identifiers and clauses in SQL statements, such as the maximum lengths of identifiers and the maximum number of columns in a select list. Limitations can be imposed by either the driver or the data source.

SQL_MAX_BINARY_LITERAL_LEN SQL_MAX_IDENTIFIER_LEN
SQL_MAX_CATALOG_NAME_LEN SQL_MAX_INDEX_SIZE
SQL_MAX_CHAR_LITERAL_LEN SQL_MAX_PROCEDURE_NAME_LEN
SQL_MAX_COLUMN_NAME_LEN SQL_MAX_ROW_SIZE
SQL_MAX_COLUMNS_IN_GROUP_BY SQL_MAX_ROW_SIZE_INCLUDES_LONG
SQL_MAX_COLUMNS_IN_INDEX SQL_MAX_SCHEMA_NAME_LEN
SQL_MAX_COLUMNS_IN_ORDER_BY SQL_MAX_STATEMENT_LEN
SQL_MAX_COLUMNS_IN_SELECT SQL_MAX_TABLE_NAME_LEN
SQL_MAX_COLUMNS_IN_TABLE SQL_MAX_TABLES_IN_SELECT
SQL_MAX_CURSOR_NAME_LEN SQL_MAX_USER_NAME_LEN

Scalar Function Information

The following values of the InfoType argument return information about the scalar functions supported by the data source and the driver. For more information about scalar functions, see Appendix 5, "Scalar Functions."

SQL_CONVERT_FUNCTIONS SQL_TIMEDATE_ADD_INTERVALS
SQL_NUMERIC_FUNCTIONS SQL_TIMEDATE_DIFF_INTERVALS
SQL_STRING_FUNCTIONS SQL_TIMEDATE_FUNCTIONS
SQL_SYSTEM_FUNCTIONS  

Conversion Information

The following values of the InfoType argument return a list of the SQL data types to which the data source can convert the specified SQL data type with the CONVERT scalar function.

SQL_CONVERT_BIGINT SQL_CONVERT_LONGVARBINARY
SQL_CONVERT_BINARY SQL_CONVERT_LONGVARCHAR
SQL_CONVERT_BIT SQL_CONVERT_NUMERIC
SQL_CONVERT_CHAR SQL_CONVERT_REAL
SQL_CONVERT_DATE SQL_CONVERT_SMALLINT
SQL_CONVERT_DECIMAL SQL_CONVERT_TIME
SQL_CONVERT_DOUBLE SQL_CONVERT_TIMESTAMP
SQL_CONVERT_FLOAT SQL_CONVERT_TINYINT
SQL_CONVERT_INTEGER SQL_CONVERT_VARBINARY
SQL_CONVERT_INTERVAL_YEAR_MONTH SQL_CONVERT_VARCHAR
SQL_CONVERT_INTERVAL_DAY_TIME  

Information Types Added for ODBC 3.0

The following values of the InfoType argument have been added for ODBC 3.0.

SQL_ACTIVE_ENVIRONMENTS SQL_DROP_ASSERTION
SQL_AGGREGATE_FUNCTIONS SQL_DROP_CHARACTER_SET
SQL_ALTER_DOMAIN SQL_DROP_COLLATION
SQL_ALTER_SCHEMA SQL_DROP_DOMAIN
SQL_ANSI_SQL_DATETIME_LITERALS SQL_DROP_SCHEMA
SQL_ASYNC_MODE SQL_DROP_TABLE
SQL_BATCH_ROW_COUNT SQL_DROP_TRANSLATION
SQL_BATCH_SUPPORT SQL_DROP_VIEW
SQL_CATALOG_NAME SQL_DYNAMIC_CURSOR_ATTRIBUTES1
SQL_COLLATION_SEQ SQL_DYNAMIC_CURSOR_ATTRIBUTES2
SQL_CONVERT_INTERVAL_YEAR_MONTH SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1
SQL_CONVERT_INTERVAL_DAY_TIME SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2
SQL_CREATE_ASSERTION SQL_INFO_SCHEMA_VIEWS
SQL_CREATE_CHARACTER_SET SQL_INSERT_STATEMENT
SQL_CREATE_COLLATION SQL_KEYSET_CURSOR_ATTRIBUTES1
SQL_CREATE_DOMAIN SQL_KEYSET_CURSOR_ATTRIBUTES2
SQL_CREATE_SCHEMA SQL_MAX_ASYNC_CONCURRENT_STATEMENTS
SQL_CREATE_TABLE SQL_MAX_IDENTIFIER_LEN
SQL_CREATE_TRANSLATION SQL_PARAM_ARRAY_ROW_COUNTS
SQL_CURSOR_SENSITIVITY SQL_PARAM_ARRAY_SELECTS
SQL_DDL_INDEX SQL_STATIC_CURSOR_ATTRIBUTES1
SQL_DESCRIBE_PARAMETER SQL_STATIC_CURSOR_ATTRIBUTES2
SQL_DM_VER SQL_XOPEN_CLI_YEAR
SQL_DRIVER_HDESC  

Information Types Renamed for ODBC 3.0

The following values of the InfoType argument have been renamed for ODBC 3.0.

ODBC 2.0 InfoType ODBC 3.0 InfoType
SQL_ACTIVE_CONNECTIONS SQL_MAX_DRIVER_CONNECTIONS
SQL_ACTIVE_STATEMENTS SQL_MAX_CONCURRENT_ACTIVITIES
SQL_MAX_OWNER_NAME_LEN SQL_MAX_SCHEMA_NAME_LEN
SQL_MAX_QUALIFIER_NAME_LEN SQL_MAX_CATALOG_NAME_LEN
SQL_ODBC_SQL_OPT_IEF SQL_INTEGRITY
SQL_OWNER_TERM SQL_SCHEMA_TERM
SQL_OWNER_USAGE SQL_SCHEMA_USAGE
SQL_QUALIFIER_LOCATION SQL_CATALOG_LOCATION
SQL_QUALIFIER_NAME_SEPARATOR SQL_CATALOG_NAME_SEPARATOR
SQL_QUALIFIER_TERM SQL_CATALOG_TERM
SQL_QUALIFIER_USAGE SQL_CATALOG_USAGE

Information Types Deprecated ODBC 3.0

The following values of the InfoType argument have been deprecated in ODBC 3.0. ODBC 3.0 drivers must continue to support these information types for backward compatibility with ODBC 2.x applications.

SQL_FETCH_DIRECTION SQL_POS_OPERATIONS
SQL_LOCK_TYPES SQL_POSITIONED_STATEMENTS
SQL_ODBC_API_CONFORMANCE SQL_SCROLL_CONCURRENCY
SQL_ODBC_SQL_CONFORMANCE SQL_STATIC_SENSITIVITY

Information Type Descriptions

For a complete description of information types, see Appendix 1. Information types description.

 

Code Example

See example 5.2 in Chapter 5.

 

Related Subroutines

For information about See
Returning the setting of a connection attribute f90SQLGetConnectAttr
Determining if a driver supports a function f90SQLGetFunctions
Returning the setting of a statement attribute f90SQLGetStmtAttr
Returning information about a data source's data types f90SQLGetTypeInfo