Jaa


SQLSetStmtAttr

The SQL Native Client ODBC driver does not support the mixed (keyset/dynamic) cursor model. Attempts to set the keyset size using SQL_ATTR_KEYSET_SIZE fail if the value set is not equal to 0.

The application sets SQL_ATTR_ROW_ARRAY_SIZE on all statements to declare the number of rows returned on a SQLFetch or SQLFetchScroll function call. On statements indicating a server cursor, the driver uses SQL_ATTR_ROW_ARRAY_SIZE to determine the size of the block of rows the server generates to satisfy a fetch request from the cursor. Within the block size of a dynamic cursor, row membership and ordering are fixed if the transaction isolation level is sufficient to ensure repeatable reads of committed transactions. The cursor is completely dynamic outside of the block indicated by this value. Server cursor block size is completely dynamic and can be changed at any point in fetch processing.

The SQL Native Client ODBC driver also supports the following driver-specific statement attributes.

SQL_SOPT_SS_CURSOR_OPTIONS

The SQL_SOPT_SS_CURSOR attribute specifies whether the driver will use driver-specific performance options on cursors. SQLGetData is not allowed when these options are set. The default setting is SQL_CO_OFF. These options are valid only when connected to an instance of SQL Server version 7.0 or later.

ValuePtr value Description

SQL_CO_OFF

Default. Disables fast forward-only, read-only cursors and autofetch, enables SQLGetData on forward-only, read-only cursors. When SQL_SOPT_SS_CURSOR_OPTIONS is set to SQL_CO_OFF, the cursor type will not change. That is, fast forward-only cursor will remain a fast forward-only cursor. To change the cursor type, the application must now set a different cursor type using SQLSetStmtAttr/SQL_ATTR_CURSOR_TYPE.

SQL_CO_FFO

Enables fast forward-only, read-only cursors, disables SQLGetData on forward-only, read-only cursors.

SQL_CO_AF

Enables the autofetch option on any cursor type. When this option is set for a statement handle, SQLExecute or SQLExecDirect will generate an implicit SQLFetchScroll (SQL_FIRST). The cursor is opened and the first batch of rows is returned in a single roundtrip to the server.

SQL_CO_FFO_AF

Enables fast forward-only cursors with the autofetch option. It is the same as if both SQL_CO_AF and SQL_CO_FFO are specified.

When these options are set, the server closes the cursor automatically when it detects that the last row has been fetched. The application must still call SQLFreeStmt(SQL_CLOSE) or SQLCloseCursor, but the driver does not have to send the close notification to the server.

If the select list contains a text, ntext, or image column, the fast forward-only cursor is converted to a dynamic cursor and SQLGetData is allowed.

SQL_SOPT_SS_DEFER_PREPARE

The SQL_SOPT_SS_DEFER_PREPARE attribute determines whether the statement is prepared immediately or deferred until SQLExecute, SQLDescribeCol or SQLDescribeParam is executed. In SQL Server 7.0 and earlier, this property is ignored (no deferred prepare).

ValuePtr value Description

SQL_DP_ON

Default. After calling SQLPrepare, the statement preparation is deferred until SQLExecute is called or metaproperty operation (SQLDescribeCol or SQLDescribeParam) is executed.

SQL_DP_OFF

The statement is prepared as soon as SQLPrepare is executed.

SQL_SOPT_SS_REGIONALIZE

The SQL_SOPT_SS_REGIONALIZE attribute is used to determine data conversion at the statement level. The attribute causes the driver to respect the client locale setting when converting date, time, and currency values to character strings. The conversion is from SQL Server native data types to character strings only.

ValuePtr value Description

SQL_RE_OFF

Default. The driver does not convert date, time, and currency data to character string data using the client locale setting.

SQL_RE_ON

The driver uses the client locale setting when converting date, time, and currency data to character string data.

Regional conversion settings apply to currency, numeric, date, and time data types. The conversion setting is only applicable to:

  • Output conversions when currency, numeric, date, or time values are converted to character strings.

  • Bulk copy in operations containing character columns when BCP6xFILEFMT is also set on.

    Note

    When the statement option SQL_SOPT_SS_REGIONALIZE is on, the driver uses the locale registry settings for the current user. The driver does not honor the current thread's locale if the application sets it by, for example, calling SetThreadLocale.

Altering the regional behavior of a data source can cause application failure. An application that parses date strings and expects date strings to appear as defined by ODBC, could be adversely affected by altering this value.

SQL_SOPT_SS_TEXTPTR_LOGGING

The SQL_SOPT_SS_TEXTPTR_LOGGING attribute toggles logging of operations on columns containing text or image data. The default behavior is to log these operations (SQL_TL_ON).

ValuePtr value Description

SQL_TL_OFF

Disables logging of operations performed on text and image data.

SQL_TL_ON

Default. Enables logging of operations performed on text and image data.

SQL_SOPT_SS_HIDDEN_COLUMNS

The SQL_SOPT_SS_HIDDEN_COLUMNS attribute exposes columns hidden in a SQL Server SELECT FOR BROWSE statement. The driver does not expose these columns by default.

ValuePtr value Description

SQL_HC_OFF

Default. FOR BROWSE columns are hidden from the result set.

SQL_HC_ON

Exposes FOR BROWSE columns.

SQL_SOPT_SS_QUERYNOTIFICATION_MSGTEXT

The SQL_SOPT_SS_QUERYNOTIFICATION_MSGTEXT attribute returns the message text for the query notification request.

SQL_SOPT_SS_QUERYNOTIFICATION_OPTIONS

The SQL_SOPT_SS_QUERYNOTIFICATION_OPTIONS attribute specifies the options used for the query notification request. These are specified in a string with name=value syntax as specified below. The user is responsible for creating the service and reading notifications off of the queue.

The syntax of the query notifications options string is:

service=<service-name>[;(local database=<database>|broker instance=<broker instance>)]

For example:

service=mySSBService;local database=mydb

SQL_SOPT_SS_QUERYNOTIFICATION_TIMEOUT

The SQL_SOPT_SS_QUERYNOTIFICATION_TIMEOUT attribute specifies the number of seconds that the query notification is to remain active. The default value is 432000 seconds (5 days).

See Also

Concepts

ODBC API Implementation Details

Other Resources

SQLGetStmtAttr Function

Help and Information

Getting SQL Server 2005 Assistance