Conformance
Version Introduced: ODBC 3.0
Standards Compliance: ISO 92
Summary
f90SQLSetStmtAttr sets attributes related to a statement.
Syntax
| f90SQLSetStmtAttr | (StatementHandle, Attribute, Value, iRet) |
| integer(SQLHENV_KIND),intent(in):: | StatementHandle |
| integer(SQLINTEGER_KIND),intent(in):: | Attribute |
| { | |
| integer(SQLINTEGER_KIND),intent(in):: | Value | |
| integer(SQLSMALLINT_KIND),intent(in):: | Value(:) | |
| character(len=*),intent(in):: | Value |
| } | |
| integer(SQLRETURN_KIND),intent(out):: | iRet |
Arguments
StatementHandle [Input]
Statement handle.
Attribute [Input]
Option to set, listed in "Comments."
Value [Input]
Value to be associated with Attribute. Depending on the value of Attribute, Value will be a 32-bit unsigned integer value or character string. When setting a pointer attribute (for example if Attribute is SQL_ATTR_PARAMS_PROCESSED_PTR) the content of Value must be an address to which the attribute-pointer will be set. When Value is a vector of SQLSMALLINT_KIND, the subroutine uses the address of the first element of in the vector (note that this is equivalent to passing loc(Value(1))). Note that if the Attribute argument is a driver-specific value, the value in Value may be a signed integer. In this case, you must use the Pointer-Format for this subroutine (See Appendix 2).
When the Pointer-Format of this subroutine is used, and if Attribute is a driver-defined attribute, the application indicates the nature of the attribute to the Driver Manager by setting the ValueStringLength argument. ValueStringLength can have the following values:
- If ValuePtr is a pointer to a character string, then ValueStringLength is the length of the string or SQL_NTS.
- If ValuePtr is a pointer to a binary buffer, then the application places the result of the f90SQLLenBinaryAttr(length) function in ValueStringLength. This places a negative value in ValueStringLength.
- If ValuePtr is a pointer to a value other than a character string or a binary string, then ValueStringLength should have the value SQL_IS_POINTER.
- If ValuePtr contains a fixed-length value, then ValueStringLength is either SQL_IS_INTEGER or SQL_IS_UINTEGER, as appropriate.
Note that the previous observations apply only for the cases in which the Pointer Format of the subroutine is used for a driver-specific attribute. For normal us of the subroutine you do not need to set ValueStringLength
iRet [Output]
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.
Diagnostics
When f90SQLSetStmtAttr returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value may be obtained by calling f90SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. The following table lists the SQLSTATE values commonly returned by f90SQLSetStmtAttr 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.) |
| 01S02 | Option value changed | The driver did not support the value specified
in Value, or the value specified in Value was invalid because of
implementation working conditions, so the driver substituted a similar value. (f90SQLGetStmtAttr can be called to determine the
temporarily substituted value.) The substitute value is valid for the StatementHandle until the cursor is closed, at which point the statement attribute reverts to its previous value. The statement attributes that can be changed are: SQL_ ATTR_CONCURRENCY (Function returns SQL_SUCCESS_WITH_INFO.) |
| 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. |
| 24000 | Invalid cursor state | The Attribute was SQL_ATTR_CONCURRENCY, SQL_ATTR_CURSOR_TYPE, SQL_ATTR_SIMULATE_CURSOR, or SQL_ATTR_USE_BOOKMARKS and the cursor was open. |
| 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. |
| HY009 | Invalid use of null pointer | The Attribute argument identified a statement attribute that required a string attribute and the Value argument was a null pointer. |
| HY010 | Function sequence error | (DM) An asynchronously executing function was
called for the StatementHandle and was still executing when this function was
called. (DM) f90SQLExecute, f90SQLExecDirect, f90SQLBulkOperations, or f90SQLSetPos was called for the StatementHandle and returned SQL_NEED_DATA. This function was called before data was sent for all data-at-execution parameters or columns. |
| HY011 | Attribute cannot be set now | The Attribute was SQL_ATTR_CONCURRENCY, SQL_ ATTR_CURSOR_TYPE, SQL_ ATTR_SIMULATE_CURSOR, or SQL_ ATTR_USE_BOOKMARKS and the statement was prepared. |
| 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. |
| HY017 | Invalid use of an automatically allocated descriptor handle | (DM) The Attribute argument was
SQL_ATTR_IMP_ROW_DESC or SQL_ATTR_IMP_PARAM_DESC. (DM) The Attribute argument was SQL_ATTR_APP_ROW_DESC or SQL_ATTR_APP_PARAM_DESC, and the value in Value was an implicitly allocated descriptor handle other than the handle originally allocated for the ARD or APD. |
| HY024 | Invalid attribute value | Given the specified Attribute value, an
invalid value was specified in Value. (The Driver Manager returns this SQLSTATE
only for connection and statement attributes that accept a discrete set of values, such as
SQL_ATTR_ACCESS_MODE or SQL_ ATTR_ASYNC_ENABLE. For all other connection and statement
attributes, the driver must verify the value specified in Value.) The Attribute argument was SQL_ATTR_APP_ROW_DESC or SQL_ATTR_APP_PARAM_DESC, and Value was an explicitly allocated descriptor handle that is not on the same connection as the StatementHandle argument. |
| HY090 | Invalid string or buffer length | (DM) Value is a character string, and the Len_trim(Value) argument was less than 0, but was not SQL_NTS. |
| HY092 | Invalid attribute/option identifier | (DM) The value specified for the argument Attribute
was not valid for the version of ODBC supported by the driver. (DM) The value specified for the argument Attribute was a read-only attribute. |
| HYC00 | Optional feature not implemented | The value specified for the argument Attribute was a valid ODBC statement attribute for the version of ODBC supported by the driver, but was not supported by the driver.The Attribute argument was SQL_ATTR_ASYNC_ENABLE and a call to f90SQLGetInfo with an InfoType of SQL_ASYNC_MODE returns SQL_AM_CONNECTION.The Attribute argument was SQL_ATTR_ENABLE_AUTO_IPD and the value of the connection attribute SQL_ATTR_AUTO_IPD was SQL_FALSE. |
| 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 associated with the StatementHandle does not support the function |
Comments
Statement attributes for a statement remain in effect until they are changed by another call to f90SQLSetStmtAttr or the statement is dropped by calling f90SQLFreeHandle. Calling f90SQLFreeStmt with the SQL_CLOSE, SQL_UNBIND, or SQL_RESET_PARAMS options does not reset statement attributes.
Some statement attributes support substitution of a similar value if the data source does not support the value specified in Value. In such cases, the driver returns SQL_SUCCESS_WITH_INFO and SQLSTATE 01S02 (Option value changed). For example, if Attribute is SQL_ATTR_CONCURRENCY, Value is SQL_CONCUR_ROWVER, and the data source does not support this, the driver substitutes SQL_CONCUR_VALUES and returns SQL_SUCCESS_WITH_INFO. To determine the substituted value, an application calls f90SQLGetStmtAttr.
The format of information set with Value depends on the specified Attribute. f90SQLSetStmtAttr accepts attribute information in one of two different formats: a character string or a 32-bit integer value. The format of each is noted in the attribute's description. This format applies to the information returned for each attribute in f90SQLGetStmtAttr. Character strings pointed in the Value argument of f90SQLSetStmtAttr have a length of Len_trim(Value).
Note: The ability to set statement attributes at the connection level by calling f90SQLSetConnectAttr has been deprecated in ODBC 3.0. ODBC 3.0 applications should never set statement attributes at the connection level. ODBC 3.0 statement attributes cannot be set at the connection level, with the exception of the SQL_ATTR_METADATA_ID and SQL_ATTR_ASYNC_ENABLE attributes, which are both connection attributes and statement attributes, and can be set either at the connection level or the statement level.
Statement Attributes that Set Descriptor Fields
Many statement attributes correspond to a header field of a descriptor. Setting these attributes actually results in the setting of the descriptor fields. Setting fields by a call to f90SQLSetStmtAttr, rather than f90SQLSetDescField, has the advantage that a descriptor handle does not have to be obtained for the function call.
Caution: Calling f90SQLSetStmtAttr for one statement can affect other statements. This occurs when the APD or ARD associated with the statement is explicitly allocated and is also associated with other statements. Because f90SQLSetStmtAttr modifies the APD or ARD, the modifications apply to all statements with which this descriptor is associated. If this is not the required behavior, the application should dissociate this descriptor from the other statements (by calling f90SQLSetStmtAttr to set the SQL_ATTR_APP_ROW_DESC or SQL_ATTR_APP_PARAM_DESC field to a different descriptor handle) before calling f90SQLSetStmtAttr again.
When a descriptor field is set as a result of the corresponding statement attribute being set, the field is set only for the applicable descriptors that are currently associated with the statement identified by the StatementHandle argument, and the attribute setting does not affect any descriptors that may be associated with that statement in the future. When a descriptor field that is also a statement attribute is set by a call to f90SQLSetDescField, the corresponding statement attribute is set. If an explicitly allocated descriptor is dissociated from a statement, a statement attribute that corresponds to a header field will revert to the value of the field in the implicitly allocated descriptor.
When a statement is allocated (see f90SQLAllocHandle), four descriptor handles are automatically allocated and associated with the statement. Explicitly allocated descriptor handles can be associated with the statement by calling f90SQLAllocHandle with an HandleType of SQL_HANDLE_DESC to allocate a descriptor handle, and then calling f90SQLSetStmtAttr to associate the descriptor handle with the statement.
The following statement attributes correspond to descriptor header fields.
| Statement attribute | Descriptor Header field | Descriptor |
| SQL_ATTR_PARAM_BIND_OFFSET_PTR | SQL_DESC_BIND_OFFSET_PTR | APD |
| SQL_ATTR_PARAM_BIND_TYPE | SQL_DESC_BIND_TYPE | APD |
| SQL_ATTR_PARAM_OPERATION_PTR | SQL_DESC_ARRAY_STATUS_PTR | APD |
| SQL_ATTR_PARAM_STATUS_PTR | SQL_DESC_ARRAY_STATUS_PTR | IPD |
| SQL_ATTR_PARAMS_PROCESSED_PTR | SQL_DESC_ROWS_PROCESSED_PTR | IPD |
| SQL_ATTR_PARAMSET_SIZE | SQL_DESC_ARRAY_SIZE | APD |
| SQL_ATTR_ROW_ARRAY_SIZE | SQL_DESC_ARRAY_SIZE | ARD |
| SQL_ATTR_ROW_BIND_OFFSET_PTR | SQL_DESC_BIND_OFFSET_PTR | ARD |
| SQL_ATTR_ROW_BIND_TYPE | SQL_DESC_BIND_TYPE | ARD |
| SQL_ATTR_ROW_OPERATION_PTR | SQL_DESC_ARRAY_STATUS_PTR | ARD |
| SQL_ATTR_ROW_STATUS_PTR | SQL_DESC_ARRAY_STATUS_PTR | IRD |
| SQL_ATTR_ROWS_FETCHED_PTR | SQL_DESC_ROWS_PROCESSED_PTR | IRD |
Statement Attributes
The currently defined attributes and the version of ODBC in which they were introduced are shown in the following table; it is expected that more will be defined by drivers to take advantage of different data sources. A range of attributes is reserved by ODBC; driver developers must reserve values for their own driver-specific use from X/Open.
| Attribute | Value Contents |
| SQL_ATTR_APP_PARAM_DESC (ODBC 3.0) |
The handle to the APD for subsequent calls to f90SQLExecute and f90SQLExecDirect on the statement handle. The initial value of this attribute is the descriptor implicitly allocated when the statement was initially allocated. If the value of this attribute is set to SQL_NULL_DESC or the handle originally allocated for the descriptor, an explicitly allocated APD handle that was previously associated with the statement handle is dissociated from it, and the statement handle reverts to the implicitly allocated APD handle. This attribute cannot be set to a descriptor handle that was implicitly allocated for another statement or to another descriptor handle that was implicitly set on the same statement; implicitly allocated descriptor handles cannot be associated with more than one statement or descriptor handle. |
| SQL_ATTR_APP_ROW_DESC (ODBC 3.0) |
The handle to the ARD for subsequent fetches on the statement handle. The initial value of this attribute is the descriptor implicitly allocated when the statement was initially allocated. If the value of this attribute is set to SQL_NULL_DESC or the handle originally allocated for the descriptor, an explicitly allocated ARD handle that was previously associated with the statement handle is dissociated from it, and the statement handle reverts to the implicitly allocated ARD handle. This attribute cannot be set to a descriptor handle that was implicitly allocated for another statement or to another descriptor handle that was implicitly set on the same statement; implicitly allocated descriptor handles cannot be associated with more than one statement or descriptor handle. |
| SQL_ATTR_ASYNC_ENABLE (ODBC 1.0) |
An SQLUINTEGER_KIND value that specifies
whether a function called with the specified statement is executed asynchronously: SQL_ASYNC_ENABLE_OFF = Off (the default)SQL_ASYNC_ENABLE_ON = On Once a function has been called asynchronously, only the original function, f90SQLCancel, f90SQLGetDiagField, or f90SQLGetDiagRec can be called on the statement, and only the original function, f90SQLAllocHandle (with a HandleType of SQL_HANDLE_STMT), f90SQLGetDiagField, f90SQLGetDiagRec, or f90SQLGetFunctions can be called on the connection associated with the statement, until the original function returns a code other than SQL_STILL_EXECUTING. Any other function called on the statement or the connection associated with the statement returns SQL_ERROR with an SQLSTATE of HY010 (Function sequence error). Functions can be called on other statements. For drivers with statement level asynchronous execution support, the statement attribute SQL_ATTR_ASYNC_ENABLE may be set. Its initial value is the same as the value of the connection level attribute with the same name at the time the statement handle was allocated. For drivers with connection-level, asynchronous-execution support, the statement attribute SQL_ATTR_ASYNC_ENABLE is read-only. Its value is the same as the value of the connection level attribute with the same name at the time the statement handle was allocated. Calling f90SQLSetStmtAttr to set SQL_ATTR_ASYNC_ENABLE when the SQL_ASYNC_MODE InfoType returns SQL_AM_CONNECTION returns SQLSTATE HYC00 (Optional feature not implemented) (See f90SQLSetConnectAttr for more information.) In general, applications should execute functions asynchronously only on single-thread operating systems. On multithread operating systems, applications should execute functions on separate threads, rather than executing them asynchronously on the same thread. No functionality is lost if drivers that only operate on multithread operating systems do not need to support asynchronous execution. The following functions can be executed asynchronously: f90SQLBulkOperations, f90SQLColAttribute, f90SQLColumnPrivileges, f90SQLColumns, SQLCopyDesc, f90SQLDescribeCol, f90SQLDescribeParam, f90SQLExecDirect, f90SQLExecute, f90SQLFetch, f90SQLFetchScroll, f90SQLForeignKeys, f90SQLGetData, f90SQLGetDescField [1], f90SQLGetDescRec [1], f90SQLGetDiagField, f90SQLGetDiagRec, f90SQLGetTypeInfo, f90SQLMoreResults, f90SQLNumParams, f90SQLNumResultCols, f90SQLParamData, f90SQLPrepare, f90SQLPrimaryKeys, f90SQLProcedureColumns, f90SQLProcedures, f90SQLPutData, f90SQLSetPos, f90SQLSpecialColumns, f90SQLStatistics, f90SQLTablePrivileges, f90SQLTables [1] These functions can be called asynchronously only if the descriptor is an implementation descriptor, not an application descriptor |
| SQL_ATTR_CONCURRENCY (ODBC 2.0) |
An SQLUINTEGER_KIND value that specifies the
cursor concurrency: SQL_CONCUR_READ_ONLY = Cursor is read-only. No updates are allowed. SQL_CONCUR_LOCK = Cursor uses the lowest level of locking sufficient to ensure that the row can be updated. SQL_CONCUR_ROWVER = Cursor uses optimistic concurrency control, comparing row versions such as SQLBase ROWID or Sybase TIMESTAMP. SQL_CONCUR_VALUES = Cursor uses optimistic concurrency control, comparing values. The default value for SQL_ATTR_CONCURRENCY is SQL_CONCUR_READ_ONLY. This attribute cannot be specified for an open cursor. If the SQL_ATTR_CURSOR_TYPE Attribute is changed to a type that does not support the current value of SQL_ATTR_CONCURRENCY, the value of SQL_ATTR_CONCURRENCY will be changed at execution time, and a warning issued when f90SQLExecDirect or f90SQLPrepare is called. If the driver supports the SELECT FOR UPDATE statement, and such a statement is executed while the value of SQL_ATTR_CONCURRENCY is set to SQL_CONCUR_READ_ONLY, an error will be returned. If the value of SQL_ATTR_CONCURRENCY is changed to a value that the driver supports for some value of SQL_ATTR_CURSOR_TYPE, but not for the current value of SQL_ATTR_CURSOR_TYPE, the value of SQL_ATTR_CURSOR_TYPE will be changed at execution time, and SQLSTATE 01S02 (Option value changed) is issued when f90SQLExecDirect or f90SQLPrepare is called. If the specified concurrency is not supported by the data source, the driver substitutes a different concurrency and returns SQLSTATE 01S02 (Option value changed). For SQL_CONCUR_VALUES, the driver substitutes SQL_CONCUR_ROWVER, and vice versa. For SQL_CONCUR_LOCK, the driver substitutes, in order, SQL_CONCUR_ROWVER or SQL_CONCUR_VALUES. The validity of the substituted value is not checked until execution time.For more information about the relationship between SQL_ATTR_CONCURRENCY and the other cursor attributes. |
| SQL_ATTR_CURSOR_SCROLLABLE (ODBC 3.0) |
An SQLUINTEGER_KIND value that specifies the
level of support that the application requires. Setting this attribute affects subsequent
calls to f90SQLExecDirect and f90SQLExecute. SQL_NONSCROLLABLE = Scrollable cursors are not required on the statement handle. If the application calls f90SQLFetchScroll on this handle, the only valid value of FetchOrientation is SQL_FETCH_NEXT. This is the default. SQL_SCROLLABLE = Scrollable cursors are required on the statement handle. When calling f90SQLFetchScroll, the application may specify any valid value of FetchOrientation, achieving cursor positioning in modes other than the sequential mode. |
| SQL_ATTR_CURSOR_SENSITIVITY (ODBC 3.0) |
An SQLUINTEGER_KIND value that specifies
whether cursors on the statement handle make visible the changes made to a result set by
another cursor. Setting this attribute affects subsequent calls to f90SQLExecDirect and f90SQLExecute.
An application can read back the value of this attribute to obtain its initial state or
its state as most recently set by the application. SQL_UNSPECIFIED = It is unspecified what the cursor type is and whether cursors on the statement handle make visible the changes made to a result set by another cursor. Cursors on the statement handle may make visible none, some, or all such changes. This is the default. SQL_INSENSITIVE = All cursors on the statement handle show the result set without reflecting any changes made to it by any other cursor. Insensitive cursors are read-only. This corresponds to a static cursor, which has a concurrency that is read-only. SQL_SENSITIVE = All cursors on the statement handle make visible all changes made to a result set by another cursor. |
| SQL_ATTR_CURSOR_TYPE (ODBC 2.0) |
An SQLUINTEGER_KIND value that specifies the
cursor type: SQL_CURSOR_FORWARD_ONLY = The cursor only scrolls forward. SQL_CURSOR_STATIC = The data in the result set is static. SQL_CURSOR_KEYSET_DRIVEN = The driver saves and uses the keys for the number of rows specified in the SQL_ATTR_KEYSET_SIZE statement attribute. SQL_CURSOR_DYNAMIC = The driver only saves and uses the keys for the rows in the rowset. The default value is SQL_CURSOR_FORWARD_ONLY. This attribute cannot be specified after the SQL statement has been prepared. If the specified cursor type is not supported by the data source, the driver substitutes a different cursor type and returns SQLSTATE 01S02 (Option value changed). For a mixed or dynamic cursor, the driver substitutes, in order, a keyset-driven or static cursor. For a keyset-driven cursor, the driver substitutes a static cursor. |
| SQL_ATTR_ENABLE_AUTO_IPD (ODBC 3.0) |
An SQLUINTEGER_KIND value that specifies
whether automatic population of the IPD is performed: SQL_TRUE = Turns on automatic population of the IPD after a call to f90SQLPrepare. SQL_FALSE = Turns off automatic population of the IPD after a call to f90SQLPrepare. (An application can still obtain IPD field information by calling f90SQLDescribeParam, if supported.) The default value of the statement attribute SQL_ATTR_ENABLE_AUTO_IPD is equal to the value of the connection attribute SQL_ATTR_ AUTO_IPD. If the connection attribute SQL_ATTR_ AUTO_IPD is SQL_FALSE, the statement attribute SQL_ATTR_ ENABLE_AUTO_IPD cannot be set to SQL_TRUE. |
| SQL_ATTR_FETCH_BOOKMARK_PTR (ODBC 3.0) |
A pointer that points to a binary bookmark
value. When f90SQLFetchScroll is called with
FetchOrientation equal to SQL_FETCH_BOOKMARK, the driver picks up the bookmark value from
this field. This field defaults to a null pointer. The value pointed to by this field is not used for delete by bookmark, update by bookmark, or fetch by bookmark operations in f90SQLBulkOperations, which use bookmarks cached in rowset buffers. |
| SQL_ATTR_IMP_PARAM_DESC (ODBC 3.0) |
The handle to the IPD. The value of this attribute is the descriptor allocated when the statement was initially allocated. The application cannot set this attribute. This attribute can be retrieved by a call to f90SQLGetStmtAttr, but not set by a call to f90SQLSetStmtAttr. |
| SQL_ATTR_IMP_ROW_DESC (ODBC 3.0) |
The handle to the IRD. The value of this attribute is the descriptor allocated when the statement was initially allocated. The application cannot set this attribute. This attribute can be retrieved by a call to f90SQLGetStmtAttr, but not set by a call to f90SQLSetStmtAttr. |
| SQL_ATTR_KEYSET_SIZE (ODBC 2.0) |
An SQLUINTEGER_KIND that specifies the number
of rows in the keyset for a keyset-driven cursor. If the keyset size is 0 (the default),
the cursor is fully keyset-driven. If the keyset size is greater than 0, the cursor is
mixed (keyset-driven within the keyset and dynamic outside of the keyset). The default
keyset size is 0. If the specified size exceeds the maximum keyset size, the driver substitutes that size and returns SQLSTATE 01S02 (Option value changed). f90SQLFetch or f90SQLFetchScroll returns an error if the keyset size is greater than 0 and less than the rowset size. |
| SQL_ATTR_MAX_LENGTH (ODBC 1.0) |
An SQLUINTEGER_KIND value that specifies the
maximum amount of data that the driver returns from a character or binary column. If Value is less than the length of the available data, f90SQLFetch or f90SQLGetData truncates the data and returns SQL_SUCCESS. If Value is 0 (the default), the driver attempts to return all available data. If the specified length is less than the minimum amount of data that the data source can return, or greater than the maximum amount of data that the data source can return, the driver substitutes that value and returns SQLSTATE 01S02 (Option value changed). The value of this attribute can be set on an open cursor; however, the setting may not take effect immediately, in which case the driver will return SQLSTATE 01S02 (Option value changed), and reset the attribute to its original value. This attribute is intended to reduce network traffic and should only be supported when the data source (as opposed to the driver) in a multiple-tier driver can implement it. This mechanism should not be used by applications to truncate data; to truncate data received, an application should specify the maximum buffer length in the BufferLength argument in f90SQLBindCol or f90SQLGetData. |
| SQL_ATTR_MAX_ROWS (ODBC 1.0) |
An SQLUINTEGER_KIND value corresponding to the
maximum number of rows to return to the application for a SELECT statement. If Value equals 0 (the default), then the driver returns all rows. This attribute is intended to reduce network traffic. Conceptually, it is applied when the result set is created and limits the result set to the first Value rows. If the number of rows in the result set is greater than Value, the result set is truncated. SQL_ATTR_MAX_ROWS applies to all result sets on the Statement, including those returned by catalog functions. SQL_ATTR_MAX_ROWS establishes a maximum for the value of the cursor row count. A driver should not emulate SQL_ATTR_MAX_ROWS behavior for f90SQLFetch or f90SQLFetchScroll (if result set size limitations cannot be implemented at the data source) if it cannot guarantee that SQL_ATTR_MAX_ROWS will be implemented properly. It is driver-defined whether SQL_ATTR_MAX_ROWS applies to statements other than SELECT statements (such as catalog functions). The value of this attribute can be set on an open cursor; however, the setting may not take effect immediately, in which case the driver will return SQLSTATE 01S02 (Option value changed), and reset the attribute to its original value. |
| SQL_ATTR_METADATA_ID (ODBC 3.0) |
An SQLUINTEGER_KIND value that determines how
the string arguments of catalog functions are treated. If SQL_TRUE, the string argument of catalog functions are treated as identifiers. The case is not significant. For non-delimited strings, the driver removes any trailing spaces, and the string is folded to uppercase. For delimited strings, the driver removes any leading or trailing spaces, and takes whatever is between the delimiters literally. If one of these arguments is set to a null pointer, the function returns SQL_ERROR and SQLSTATE HY009 (Invalid use of null pointer). If SQL_FALSE, the string arguments of catalog functions are not treated as identifiers. The case is significant. They can either contain a string search pattern or not, depending on the argument. The default value is SQL_FALSE.The TableType argument of f90SQLTables, which takes a list of values, is not affected by this attribute.SQL_ATTR_METADATA_ID can also be set on the connection level. (It and SQL_ATTR_ASYNC_ENABLE are the only statement attributes that are also connection attributes). |
| SQL_ATTR_NOSCAN (ODBC 1.0) |
An SQLUINTEGER_KIND value that indicates
whether the driver should scan SQL strings for escape sequences: SQL_NOSCAN_OFF = The driver scans SQL strings for escape sequences (the default). SQL_NOSCAN_ON = The driver does not scan SQL strings for escape sequences. Instead, the driver sends the statement directly to the data source. |
| SQL_ATTR_PARAM_BIND_OFFSET_PTR (ODBC 3.0) |
A pointer to a SQLUINTEGER_KIND integer that
is an offset added to pointers to change binding of dynamic parameters. If this field is
non-null, the driver dereferences the pointer, adds the dereferenced value to each of the
deferred fields in the descriptor record (SQL_DESC_DATA_PTR, SQL_DESC_INDICATOR_PTR, and
SQL_DESC_OCTET_LENGTH_PTR), and uses the new pointer values when binding. It is set to
null by default. The bind offset is always added directly to the SQL_DESC_DATA_PTR,
SQL_DESC_INDICATOR_PTR, and SQL_DESC_OCTET_LENGTH_PTR fields. If the offset is changed to a different value, the new value is still added directly to the value in the descriptor field. The new offset is not added to the field value plus any earlier offsets. |
| SQL_ATTR_PARAM_BIND_TYPE (ODBC 3.0) |
An SQLUINTEGER_KIND value that indicates the binding orientation to be used for dynamic parameters. This field is set to SQL_PARAM_BIND_BY_COLUMN (the default) to select column-wise binding. To select row-wise binding, this field is set to the length of the structure or an instance of a buffer that will be bound to a set of dynamic parameters. This length must include space for all of the bound parameters and any padding of the structure or buffer to ensure that when the address of a bound parameter is incremented with the specified length, the result will point to the beginning of the same parameter in the next set of parameters. When using the sizeof operator in ANSI C, this behavior is guaranteed. |
| SQL_ATTR_PARAM_OPERATION_PTR (ODBC 3.0) |
A pointer that points to an array of
SQLUSMALLINT_KIND values used to ignore a parameter during execution of an SQL statement.
Each value is set to either SQL_PARAM_PROCEED (for the parameter to be executed) or
SQL_PARAM_IGNORE (for the parameter to be ignored). A set of parameters can be ignored
during processing by setting the status value in the array pointed to by
SQL_DESC_ARRAY_STATUS_PTR in the APD to SQL_PARAM_IGNORE. A set of parameters is processed
if its status value is set to SQL_PARAM_PROCEED, or if no elements in the array are set. This statement attribute can be set to a null pointer, in which case the driver does not return parameter status values. This attribute can be set at any time, but the new value is not used until the next time f90SQLExecDirect or f90SQLExecute is called. |
| SQL_ATTR_PARAM_STATUS_PTR (ODBC 3.0) |
A pointer that points to an array of
SQLUSMALLINT_KIND values containing status information for each row of parameter values
after a call to f90SQLExecute or f90SQLExecDirect. This field is required only if
PARAMSET_SIZE is greater than 1. The status values can contain the following values: SQL_PARAM_SUCCESS: The SQL statement was successfully executed for this set of parameters. SQL_PARAM_SUCCESS_WITH_INFO: The SQL statement was successfully executed for this set of parameters; however, warning information is available in the diagnostics data structure. SQL_PARAM_ERROR: There was an error in processing this set of parameters. Additional error information is available in the diagnostics data structure. SQL_PARAM_UNUSED: This parameter set was unused, possibly due to the fact that some previous parameter set caused an error that aborted further processing, or because SQL_PARAM_IGNORE was set for that set of parameters in the array specified by the SQL_ATTR_PARAM_OPERATION_PTR. SQL_PARAM_DIAG_UNAVAILABLE: The driver treats arrays of parameters as a monolithic unit and so does not generate this level of error information. This statement attribute can be set to a null pointer, in which case the driver does not return parameter status values. This attribute can be set at any time, but the new value is not used until the next time f90SQLExecute or f90SQLExecDirect is called. Note that setting this attribute may affect the output parameter behavior implemented by the driver. |
| SQL_ATTR_PARAMS_PROCESSED_PTR (ODBC 3.0) |
A pointer that points to a SQLUINTEGER_KIND
buffer in which to return the number of sets of parameters that have been processed,
including error sets. No number will be returned if this is a null pointer. Setting this
statement attribute sets the SQL_DESC_ROWS_PROCESSED_PTR field in the IPD header. If the call to f90SQLExecDirect or f90SQLExecute that fills in the buffer pointed to by this attribute does not return SQL_SUCCESS or SQL_SUCCESS_WITH_INFO, the contents of the buffer are undefined. |
| SQL_ATTR_PARAMSET_SIZE (ODBC 3.0) |
An SQLUINTEGER_KIND value that specifies the number of values for each parameter. If SQL_ATTR_PARAMSET_SIZE is greater than 1, SQL_DESC_DATA_PTR, SQL_DESC_INDICATOR_PTR, and SQL_DESC_OCTET_LENGTH_PTR of the APD point to arrays. The cardinality of each array is equal to the value of this field. |
| SQL_ATTR_QUERY_TIMEOUT (ODBC 1.0) |
An SQLUINTEGER_KIND value corresponding to the number of seconds to wait for an SQL statement to execute before returning to the application. If Value is equal to 0 (default), then there is no timeout. If the specified timeout exceeds the maximum timeout in the data source or is smaller than the minimum timeout, f90SQLSetStmtAttr substitutes that value and returns SQLSTATE 01S02 (Option value changed). Note that the application need not call f90SQLCloseCursor to reuse the statement if a SELECT statement timed out. The query timeout set in this statement attribute is valid in both synchronous and asynchronous modes. |
| SQL_ATTR_RETRIEVE_DATA (ODBC 2.0) |
An SQLUINTEGER_KIND value: SQL_RD_ON = f90SQLFetchScroll and in ODBC 3.0, f90SQLFetch, retrieve data after it positions the cursor to the specified location. This is the default. SQL_RD_OFF = f90SQLFetchScroll and in ODBC 3.0, f90SQLFetch, do not retrieve data after it positions the cursor. By setting SQL_RETRIEVE_DATA to SQL_RD_OFF, an application can verify that a row exists or retrieve a bookmark for the row without incurring the overhead of retrieving rows. The value of this attribute can be set on an open cursor; however, the setting may not take effect immediately, in which case the driver will return SQLSTATE 01S02 (Option value changed), and reset the attribute to its original value. |
| SQL_ATTR_ROW_ARRAY_SIZE (ODBC 3.0) |
An SQLUINTEGER_KIND value that specifies the number of rows returned by each call to f90SQLFetch or f90SQLFetchScroll. It is also the number of rows in a bookmark array used in a bulk bookmark operation in f90SQLBulkOperations. The default value is 1.If the specified rowset size exceeds the maximum rowset size supported by the data source, the driver substitutes that value and returns SQLSTATE 01S02 (Option value changed). |
| SQL_ATTR_ROW_BIND_OFFSET_PTR (ODBC 3.0) |
An pointer to a SQLUINTEGER_KIND value that is
an offset added to pointers to change binding of column data. If this field is non-null,
the driver dereferences the pointer, adds the dereferenced value to each of the deferred
fields in the descriptor record (SQL_DESC_DATA_PTR, SQL_DESC_INDICATOR_PTR, and
SQL_DESC_OCTET_LENGTH_PTR), and uses the new pointer values when binding. It is set to null by default. Setting this statement attribute sets the SQL_DESC_BIND_OFFSET_PTR field in the ARD header. |
| SQL_ATTR_ROW_BIND_TYPE (ODBC 1.0) |
An SQLUINTEGER_KIND value that sets the binding orientation to be used when f90SQLFetch or f90SQLFetchScroll is called on the associated statement. Column-wise binding is selected by setting the value to SQL_BIND_BY_COLUMN. Row-wise binding is selected by setting the value to the length of a structure or an instance of a buffer into which result columns will be bound. If a length is specified, it must include space for all of the bound columns and any padding of the structure or buffer to ensure that when the address of a bound column is incremented with the specified length, the result will point to the beginning of the same column in the next row. When using the sizeof operator with structures or unions in ANSI C, this behavior is guaranteed. Column-wise binding is the default binding orientation for f90SQLFetch and f90SQLFetchScroll. |
| SQL_ATTR_ROW_NUMBE R(ODBC 2.0) |
An SQLUINTEGER_KIND value that is the number of the current row in the entire result set. If the number of the current row cannot be determined or there is no current row, the driver returns 0.This attribute can be retrieved by a call to f90SQLGetStmtAttr, but not set by a call to f90SQLSetStmtAttr. |
| SQL_ATTR_ROW_OPERATION_PTR (ODBC 3.0) |
A pointer that points to an array of SQLUSMALLINT_KIND values used to ignore a row during a bulk operation using f90SQLSetPos. Each value is set to either SQL_ROW_PROCEED (for the row to be included in the bulk operation) or SQL_ROW_IGNORE (for the row to be excluded from the bulk operation). (Rows cannot be ignored by using this array during calls to f90SQLBulkOperations.) This statement attribute can be set to a null pointer, in which case the driver does not return row status values. This attribute can be set at any time, but the new value is not used until the next time f90SQLSetPos is called. |
| SQL_ATTR_ROW_STATUS_PTR (ODBC 3.0) |
A pointer that points to an array of SQLUSMALLINT_KIND values containing row status values after a call to f90SQLFetch or f90SQLFetchScroll. The array has as many elements as there are rows in the rowset. This statement attribute can be set to a null pointer, in which case the driver does not return row status values. This attribute can be set at any time, but the new value is not used until the next time f90SQLBulkOperations, f90SQLFetch, f90SQLFetchScroll, or f90SQLSetPos is called. Setting this statement attribute sets the SQL_DESC_ARRAY_STATUS_PTR field in the IRD header. This attribute is mapped by an ODBC 2.x driver to the rgbRowStatus array in a call to SQLExtendedFetch. |
| SQL_ATTR_ROWS_FETCHED_PTR (ODBC 3.0) |
A pointer that points to a SQLUINTEGER_KIND
buffer in which to return the number of rows fetched after a call to f90SQLFetch or f90SQLFetchScroll;
the number of rows affected by a bulk operation performed by a call to f90SQLSetPos with an Operation argument of SQL_REFRESH;
or the number of rows affected by a bulk operation performed by f90SQLBulkOperations. This number includes error rows. Setting this statement attribute sets the SQL_DESC_ROWS_PROCESSED_PTR field in the IRD header. If the call to f90SQLFetch or f90SQLFetchScroll that fills in the buffer pointed to by this attribute does not return SQL_SUCCESS or SQL_SUCCESS_WITH_INFO, the contents of the buffer are undefined. |
| SQL_ATTR_SIMULATE_CURSOR (ODBC 2.0) |
An SQLUINTEGER_KIND value that specifies
whether drivers that simulate positioned update and delete statements guarantee that such
statements affect only one single row. To simulate positioned update and delete
statements, most drivers construct a searched UPDATE or DELETE statement containing a
WHERE clause that specifies the value of each column in the current row. Unless these
columns make up a unique key, such a statement may affect more than one row. To guarantee
that such statements affect only one row, the driver determines the columns in a unique
key and adds these columns to the result set. If an application guarantees that the
columns in the result set make up a unique key, the driver is not required to do so. This
may reduce execution time. SQL_SC_NON_UNIQUE = The driver does not guarantee that simulated positioned update or delete statements will affect only one row; it is the application's responsibility to do so. If a statement affects more than one row, f90SQLExecute, f90SQLExecDirect, or f90SQLSetPos returns SQLSTATE 01001 (Cursor operation conflict). SQL_SC_TRY_UNIQUE = The driver attempts to guarantee that simulated positioned update or delete statements affect only one row. The driver always executes such statements, even if they might affect more than one row, such as when there is no unique key. If a statement affects more than one row, f90SQLExecute, f90SQLExecDirect, or f90SQLSetPos returns SQLSTATE 01001 (Cursor operation conflict). SQL_SC_UNIQUE = The driver guarantees that simulated positioned update or delete statements affect only one row. If the driver cannot guarantee this for a given statement, f90SQLExecDirect or f90SQLPrepare returns an error. If the data source provides native SQL support for positioned update and delete statements, and the driver does not simulate cursors, SQL_SUCCESS is returned when SQL_SC_UNIQUE is requested for SQL_SIMULATE_CURSOR. SQL_SUCCESS_WITH_INFO is returned if SQL_SC_TRY_UNIQUE or SQL_SC_NON_UNIQUE is requested. If the data source provides the SQL_SC_TRY_UNIQUE level of support, and the driver does not, SQL_SUCCESS is returned for SQL_SC_TRY_UNIQUE and SQL_SUCCESS_WITH_INFO is returned for SQL_SC_NON_UNIQUE.If the specified cursor simulation type is not supported by the data source, the driver substitutes a different simulation type and returns SQLSTATE 01S02 (Option value changed). For SQL_SC_UNIQUE, the driver substitutes, in order, SQL_SC_TRY_UNIQUE or SQL_SC_NON_UNIQUE. For SQL_SC_TRY_UNIQUE, the driver substitutes SQL_SC_NON_UNIQUE. |
| SQL_ATTR_USE_BOOKMARKS (ODBC 2.0) |
An SQLUINTEGER_KIND value that specifies
whether an application will use bookmarks with a cursor: SQL_UB_OFF = Off (the default) SQL_UB_VARIABLE = An application will use bookmarks with a cursor, and the driver will provide variable-length bookmarks if they are supported. SQL_UB_FIXED is deprecated in ODBC 3.0. ODBC 3.0 applications should always use variable-length bookmarks, even when working with ODBC 2.x drivers (which supported only 4-byte, fixed-length bookmarks). This is because a fixed-length bookmark is just a special case of a variable-length bookmark. When working with an ODBC 2.x driver, the Driver Manager maps SQL_UB_VARIABLE to SQL_UB_FIXED.To use bookmarks with a cursor, the application must specify this attribute with the SQL_UB_VARIABLE value before opening the cursor. |
Code Example
See "Column-Wise Binding" and "Row-Wise Binding" in Chapter 5, and example in f90SQLCopyDesc.
Related Subroutines
| For information about | See |
| Canceling statement processing | f90SQLCancel |
| Returning the setting of a connection attribute | f90SQLGetConnectAttr |
| Returning the setting of a statement attribute | f90SQLGetStmtAttr |
| Setting a connection attribute | f90SQLSetConnectAttr |
| Setting a single field of the descriptor | f90SQLSetDescField |