SQLSetStmtAttr 函数SQLSetStmtAttr Function

Conformance
引入的版本: ODBC 3.0 标准符合性: ISO 92Version Introduced: ODBC 3.0 Standards Compliance: ISO 92

总结Summary
SQLSetStmtAttr设置与语句相关的属性。SQLSetStmtAttr sets attributes related to a statement.

备注

有关 ODBC 3.x 应用程序**使用 odbc 2.x驱动程序时,驱动程序管理器将此函数映射到的内容的详细信息,请参阅为应用程序的向后兼容性映射替换函数For more information about what the Driver Manager maps this function to when an ODBC 3.x application is working with an ODBC 2.x driver, see Mapping Replacement Functions for Backward Compatibility of Applications.

语法Syntax

  
SQLRETURN SQLSetStmtAttr(  
     SQLHSTMT      StatementHandle,  
     SQLINTEGER    Attribute,  
     SQLPOINTER    ValuePtr,  
     SQLINTEGER    StringLength);  

参数Arguments

StatementHandleStatementHandle
送语句句柄。[Input] Statement handle.

AttributeAttribute
送要设置的选项,请在 "注释" 中列出。[Input] Option to set, listed in "Comments."

将 valueptrValuePtr
送要与属性关联的值。[Input] Value to be associated with Attribute. 根据属性的值,将 valueptr将是以下项之一:Depending on the value of Attribute, ValuePtr will be one of the following:

  • ODBC 描述符句柄。An ODBC descriptor handle.

  • SQLUINTEGER 值。A SQLUINTEGER value.

  • SQLULEN 生成值。A SQLULEN value.

  • 指向以下项之一的指针:A pointer to one of the following:

    • 以 null 值结束的字符串。A null-terminated character string.

    • 二进制缓冲区。A binary buffer.

    • 类型为 SQLLEN、SQLULEN 生成或 SQLUSMALLINT 的值或数组。A value or array of type SQLLEN, SQLULEN, or SQLUSMALLINT.

    • 驱动程序定义的值。A driver-defined value.

如果特性参数是驱动程序特定的值,则将 valueptr可能是一个有符号整数。If the Attribute argument is a driver-specific value, ValuePtr may be a signed integer.

StringLengthStringLength
送如果attribute是一个 ODBC 定义的属性,并且将 valueptr指向某个字符串或二进制缓冲区,则此参数应为*将 valueptr的长度。[Input] If Attribute is an ODBC-defined attribute and ValuePtr points to a character string or a binary buffer, this argument should be the length of *ValuePtr. 如果attribute是一个 ODBC 定义的属性,并且将 valueptr是一个整数,则将忽略StringLengthIf Attribute is an ODBC-defined attribute and ValuePtr is an integer, StringLength is ignored.

如果attribute是驱动程序定义的属性,则应用程序通过设置StringLength参数来指示属性对驱动程序管理器的性质。If Attribute is a driver-defined attribute, the application indicates the nature of the attribute to the Driver Manager by setting the StringLength argument. StringLength可具有以下值:StringLength can have the following values:

  • 如果将 valueptr是指向字符串的指针,则StringLength是字符串或 SQL_NTS 的长度。If ValuePtr is a pointer to a character string, then StringLength is the length of the string or SQL_NTS.

  • 如果将 valueptr是指向二进制缓冲区的指针,则该应用程序会将 SQL_LEN_BINARY_ATTR (长度)宏的结果放置在StringLength中。If ValuePtr is a pointer to a binary buffer, then the application places the result of the SQL_LEN_BINARY_ATTR(length) macro in StringLength. 这会在StringLength中置入负值。This places a negative value in StringLength.

  • 如果将 valueptr是一个指向字符串或二进制字符串以外的值的指针,则StringLength的值应 SQL_IS_POINTER。If ValuePtr is a pointer to a value other than a character string or a binary string, then StringLength should have the value SQL_IS_POINTER.

  • 如果将 valueptr包含固定长度的值,则StringLength根据需要 SQL_IS_INTEGER 或 SQL_IS_UINTEGER。If ValuePtr contains a fixed-length value, then StringLength is either SQL_IS_INTEGER or SQL_IS_UINTEGER, as appropriate.

返回Returns

SQL_SUCCESS、SQL_SUCCESS_WITH_INFO、SQL_ERROR 或 SQL_INVALID_HANDLE。SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.

诊断Diagnostics

SQLSetStmtAttr返回 SQL_ERROR 或 SQL_SUCCESS_WITH_INFO 时,可以通过使用HandleType的 SQL_HANDLE_STMT 和StatementHandle句柄调用SQLGetDiagRec来获取关联的 SQLSTATE 值。When SQLSetStmtAttr returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value may be obtained by calling SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. 下表列出了通常由SQLSetStmtAttr返回的 SQLSTATE 值,并对该函数的上下文中的每个值进行了说明:"(DM)" 表示法位于驱动程序管理器返回的 SQLSTATEs 的说明之前。The following table lists the SQLSTATE values commonly returned by SQLSetStmtAttr and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. 除非另有说明,否则与每个 SQLSTATE 值相关联的返回代码将 SQL_ERROR。The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.

SQLSTATESQLSTATE 错误Error 说明Description
0100001000 一般警告General warning 驱动程序特定的信息性消息。Driver-specific informational message. (函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
01S0201S02 选项值已更改Option value changed 该驱动程序不支持将 valueptr中指定的值,或者在将 valueptr中指定的值因实现工作条件而无效,因此驱动程序将替换相似的值。The driver did not support the value specified in ValuePtr, or the value specified in ValuePtr was invalid because of implementation working conditions, so the driver substituted a similar value. (可以调用SQLGetStmtAttr来确定暂时替换的值。)替换值对StatementHandle有效,直到游标关闭,此时语句特性会恢复为其以前的值。(SQLGetStmtAttr 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 SQL_ ATTR_CURSOR_TYPE SQL_ ATTR_KEYSET_SIZE SQL_ ATTR_MAX_LENGTH SQL_ ATTR_MAX_ROWS SQL_ ATTR_QUERY_TIMEOUT SQL_ATTR_ROW_ARRAY_SIZE SQL_ ATTR_SIMULATE_CURSORSQL_ ATTR_CONCURRENCY SQL_ ATTR_CURSOR_TYPE SQL_ ATTR_KEYSET_SIZE SQL_ ATTR_MAX_LENGTH SQL_ ATTR_MAX_ROWS SQL_ ATTR_QUERY_TIMEOUT SQL_ATTR_ROW_ARRAY_SIZE SQL_ ATTR_SIMULATE_CURSOR

(函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
08S0108S01 通信链接失败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.
2400024000 无效的游标状态Invalid cursor state 属性已 SQL_ATTR_CONCURRENCY、SQL_ATTR_CURSOR_TYPE、SQL_ATTR_SIMULATE_CURSOR 或 SQL_ATTR_USE_BOOKMARKS,并且游标已打开。The Attribute was SQL_ATTR_CONCURRENCY, SQL_ATTR_CURSOR_TYPE, SQL_ATTR_SIMULATE_CURSOR, or SQL_ATTR_USE_BOOKMARKS, and the cursor was open.
HY000HY000 常规错误General error 发生了一个错误,该错误没有特定的 SQLSTATE,没有为其定义实现特定的 SQLSTATE。An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. MessageText 缓冲区中的SQLGetDiagRec返回的错误消息描述了错误及其原因。 * **The error message returned by SQLGetDiagRec in the *MessageText buffer describes the error and its cause.
HY001HY001 内存分配错误Memory allocation error 驱动程序无法分配支持执行或完成此函数所需的内存。The driver was unable to allocate memory required to support execution or completion of the function.
HY009HY009 空值指针的使用无效Invalid use of null pointer 特性参数标识了需要字符串特性的语句特性,而将 valueptr参数为 null 指针。The Attribute argument identified a statement attribute that required a string attribute, and the ValuePtr argument was a null pointer.
HY010HY010 函数序列错误Function sequence error (DM)为与StatementHandle关联的连接句柄调用了异步执行的函数。(DM) An asynchronously executing function was called for the connection handle that is associated with the StatementHandle. 调用SQLSetStmtAttr函数时,此异步函数仍在执行。This asynchronous function was still executing when the SQLSetStmtAttr function was called.

StatementHandle调用了SQLExecuteSQLExecDirectSQLMoreResults ,并返回 SQL_PARAM_DATA_AVAILABLE。(DM) SQLExecute, SQLExecDirect, or SQLMoreResults was called for the StatementHandle and returned SQL_PARAM_DATA_AVAILABLE. 在检索所有流式处理参数的数据之前调用此函数。This function was called before data was retrieved for all streamed parameters.

(DM)为StatementHandle调用了异步执行的函数,并且在调用此函数时仍在执行该函数。(DM) An asynchronously executing function was called for the StatementHandle and was still executing when this function was called.

(DM) SQLExecuteSQLExecDirectSQLBulkOperationsSQLSetPos调用了StatementHandle并返回 SQL_NEED_DATA。(DM) SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos 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.
HY011HY011 现在无法设置属性Attribute cannot be set now 属性已 SQL_ATTR_CONCURRENCY、SQL_ ATTR_CURSOR_TYPE、SQL_ ATTR_SIMULATE_CURSOR 或 SQL_ ATTR_USE_BOOKMARKS 并且已准备好该语句。The Attribute was SQL_ATTR_CONCURRENCY, SQL_ ATTR_CURSOR_TYPE, SQL_ ATTR_SIMULATE_CURSOR, or SQL_ ATTR_USE_BOOKMARKS, and the statement was prepared.
HY013HY013 内存管理错误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.
HY017HY017 使用自动分配的描述符句柄无效Invalid use of an automatically allocated descriptor handle (DM) SQL_ATTR_IMP_ROW_DESC 或 SQL_ATTR_IMP_PARAM_DESC属性参数。(DM) The Attribute argument was SQL_ATTR_IMP_ROW_DESC or SQL_ATTR_IMP_PARAM_DESC.

(DM)属性参数 SQL_ATTR_APP_ROW_DESC 或 SQL_ATTR_APP_PARAM_DESC,将 valueptr中的值是隐式分配的描述符句柄,而不是最初为 ARD 或 APD 分配的句柄。(DM) The Attribute argument was SQL_ATTR_APP_ROW_DESC or SQL_ATTR_APP_PARAM_DESC, and the value in ValuePtr was an implicitly allocated descriptor handle other than the handle originally allocated for the ARD or APD.
HY024HY024 属性值无效Invalid attribute value 给定指定的属性值,将 valueptr中指定的值无效。Given the specified Attribute value, an invalid value was specified in ValuePtr. (驱动程序管理器只为接受一组离散值(如 SQL_ATTR_ACCESS_MODE 或 SQL_ ATTR_ASYNC_ENABLE 的连接和语句属性返回此 SQLSTATE。(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. 对于所有其他连接和语句属性,驱动程序必须验证将 valueptr中指定的值。)For all other connection and statement attributes, the driver must verify the value specified in ValuePtr.)

特性参数是 SQL_ATTR_APP_ROW_DESC 或 SQL_ATTR_APP_PARAM_DESC,将 valueptr是显式分配的描述符句柄,该句柄不在与StatementHandle参数相同的连接上。The Attribute argument was SQL_ATTR_APP_ROW_DESC or SQL_ATTR_APP_PARAM_DESC, and ValuePtr was an explicitly allocated descriptor handle that is not on the same connection as the StatementHandle argument.
HY090HY090 字符串或缓冲区长度无效Invalid string or buffer length (DM) * *将 valueptr*是一个字符串, StringLength参数小于0,但未 SQL_NTS。(DM) *ValuePtr is a character string, and the StringLength argument was less than 0 but was not SQL_NTS.
HY092HY092 无效的属性/选项标识符Invalid attribute/option identifier (DM)为参数属性指定的值对于该驱动程序支持的 ODBC 版本无效。(DM) The value specified for the argument Attribute was not valid for the version of ODBC supported by the driver.

(DM)为参数属性指定的值为只读属性。(DM) The value specified for the argument Attribute was a read-only attribute.
HY117HY117 由于未知的事务状态,连接被挂起。Connection is suspended due to unknown transaction state. 仅允许断开连接和只读函数。Only disconnect and read-only functions are allowed. (DM)有关挂起状态的详细信息,请参阅SQLEndTran 函数(DM) For more information about suspended state, see SQLEndTran Function.
HYC00HYC00 未实现的可选功能Optional feature not implemented 为 argument特性指定的值为驱动程序支持的 odbc 版本的有效 odbc 语句属性,但驱动程序不支持该属性。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.

特性参数已 SQL_ATTR_ASYNC_ENABLE,对InfoType为 SQL_ASYNC_MODE 的SQLGetInfo的调用返回 SQL_AM_CONNECTION。The Attribute argument was SQL_ATTR_ASYNC_ENABLE, and a call to SQLGetInfo with an InfoType of SQL_ASYNC_MODE returns SQL_AM_CONNECTION.

特性参数 SQL_ATTR_ENABLE_AUTO_IPD,而连接属性 SQL_ATTR_AUTO_IPD 的值 SQL_FALSE 为。The Attribute argument was SQL_ATTR_ENABLE_AUTO_IPD, and the value of the connection attribute SQL_ATTR_AUTO_IPD was SQL_FALSE.
HYT01HYT01 连接超时已过期Connection timeout expired 连接超时期限在数据源响应请求之前过期。The connection timeout period expired before the data source responded to the request. 连接超时期限通过SQLSetConnectAttr设置,SQL_ATTR_CONNECTION_TIMEOUT。The connection timeout period is set through SQLSetConnectAttr, SQL_ATTR_CONNECTION_TIMEOUT.
IM001IM001 驱动程序不支持此功能Driver does not support this function (DM)与StatementHandle关联的驱动程序不支持该函数。(DM) The driver associated with the StatementHandle does not support the function.
S1118S1118 驱动程序不支持异步通知Driver does not support asynchronous notification 如果调用SQLSetStmtAttr SQL_ATTR_ASYNC_STMT_EVENT 设置,则为;驱动程序不支持异步通知。If calling SQLSetStmtAttr to set SQL_ATTR_ASYNC_STMT_EVENT; asynchronous notification is not supported by the driver.

注释Comments

语句的语句特性始终有效,直到对SQLSetStmtAttr的另一次调用更改或通过调用SQLFreeHandle删除该语句。Statement attributes for a statement remain in effect until they are changed by another call to SQLSetStmtAttr or until the statement is dropped by calling SQLFreeHandle. 用 SQL_CLOSE、SQL_UNBIND 或 SQL_RESET_PARAMS 选项调用SQLFreeStmt不会重置语句特性。Calling SQLFreeStmt with the SQL_CLOSE, SQL_UNBIND, or SQL_RESET_PARAMS option does not reset statement attributes.

如果数据源不支持将 valueptr中指定的值,则某些语句特性支持替换相似的值。Some statement attributes support substitution of a similar value if the data source does not support the value specified in ValuePtr. 在这种情况下,驱动程序将返回 SQL_SUCCESS_WITH_INFO 和 SQLSTATE 01S02 (选项值已更改)。In such cases, the driver returns SQL_SUCCESS_WITH_INFO and SQLSTATE 01S02 (Option value changed). 例如,如果属性为 SQL_ATTR_CONCURRENCY 并且将 valueptr是 SQL_CONCUR_ROWVER 的,并且数据源不支持此功能,则驱动程序将替换 SQL_CONCUR_VALUES 并返回 SQL_SUCCESS_WITH_INFO。For example, if Attribute is SQL_ATTR_CONCURRENCY and ValuePtr is SQL_CONCUR_ROWVER, and if the data source does not support this, the driver substitutes SQL_CONCUR_VALUES and returns SQL_SUCCESS_WITH_INFO. 若要确定替换值,应用程序将调用SQLGetStmtAttrTo determine the substituted value, an application calls SQLGetStmtAttr.

将 valueptr设置的信息的格式取决于指定的属性The format of information set with ValuePtr depends on the specified Attribute. SQLSetStmtAttr接受以下两种不同格式的特性信息:字符串或整数值。SQLSetStmtAttr accepts attribute information in one of two different formats: a character string or an integer value. 每个的格式记录在属性的说明中。The format of each is noted in the attribute's description. 此格式适用于在SQLGetStmtAttr中为每个属性返回的信息。This format applies to the information returned for each attribute in SQLGetStmtAttr. SQLSetStmtAttr将 valueptr参数指向的字符串的长度为StringLengthCharacter strings pointed to by the ValuePtr argument of SQLSetStmtAttr have a length of StringLength.

备注

通过调用SQLSetConnectAttr在连接级别设置语句属性的功能已在 ODBC 2.x 中弃用。The ability to set statement attributes at the connection level by calling SQLSetConnectAttr has been deprecated in ODBC 3.x. ODBC 2.x应用程序决不应在连接级别设置语句属性。ODBC 3.x applications should never set statement attributes at the connection level. ODBC 2.x语句特性不能在连接级别设置,但 SQL_ATTR_METADATA_ID 和 SQL_ATTR_ASYNC_ENABLE 属性(它们都是连接属性和语句特性)除外,可以在连接级别或语句级别设置。ODBC 3.x 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 at either the connection level or the statement level.

备注

如果 ODBC 2.x 驱动程序应使用在连接级别设置 ODBC 2.x 语句选项odbc 2.x 应用程序, 则只需支持此功能。ODBC 3.x drivers need only support this functionality if they should work with ODBC 2.x applications that set ODBC 2.x statement options at the connection level. 有关详细信息,请参阅附录 G:用于向后兼容的驱动程序准则中的SQLSetConnectOption 映射中的 "在连接级别设置语句选项"。For more information, see "Setting Statement Options on the Connection Level" under SQLSetConnectOption Mapping in Appendix G: Driver Guidelines for Backward Compatibility.

设置描述符字段的语句特性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. 通过调用SQLSetStmtAttr而不是SQLSetDescField设置字段具有这样的优点:不必为函数调用获取描述符句柄。Setting fields by a call to SQLSetStmtAttr rather than to SQLSetDescField has the advantage that a descriptor handle does not have to be obtained for the function call.

注意

对一个语句调用SQLSetStmtAttr可能会影响其他语句。Calling SQLSetStmtAttr for one statement can affect other statements. 当显式分配与该语句关联的 APD 或 ARD 并同时与其他语句关联时,会发生这种情况。This occurs when the APD or ARD associated with the statement is explicitly allocated and is also associated with other statements. 由于SQLSetStmtAttr修改了 APD 或 ARD,因此修改应用于与此描述符关联的所有语句。Because SQLSetStmtAttr modifies the APD or ARD, the modifications apply to all statements with which this descriptor is associated. 如果这不是所需的行为,应用程序应将此描述符与其他语句取消关联(通过调用SQLSetStmtAttr ,将 SQL_ATTR_APP_ROW_DESC 或 SQL_ATTR_APP_PARAM_DESC 字段设置为其他描述符句柄),然后再次调用SQLSetStmtAttrIf this is not the required behavior, the application should dissociate this descriptor from the other statements (by calling SQLSetStmtAttr to set the SQL_ATTR_APP_ROW_DESC or SQL_ATTR_APP_PARAM_DESC field to a different descriptor handle) before calling SQLSetStmtAttr again.

如果将描述符字段设置为所设置的相应语句属性的结果,则仅为当前与StatementHandle参数标识的语句相关联的适用描述符设置该字段,并且该属性设置不会影响将来可能与该语句关联的所有描述符。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. 当也是语句属性的描述符字段通过调用SQLSetDescField设置时,将设置相应的语句属性。When a descriptor field that is also a statement attribute is set by a call to SQLSetDescField, 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.

如果分配了语句(请参阅SQLAllocHandle),将自动分配四个描述符句柄并将其与该语句关联。When a statement is allocated (see SQLAllocHandle), four descriptor handles are automatically allocated and associated with the statement. 可以通过使用 SQL_HANDLE_DESC 的fHandleType调用SQLAllocHandle来关联显式分配的描述符句柄,以便分配描述符句柄,然后调用SQLSetStmtAttr以将描述符句柄与语句相关联。Explicitly allocated descriptor handles can be associated with the statement by calling SQLAllocHandle with an fHandleType of SQL_HANDLE_DESC to allocate a descriptor handle and then calling SQLSetStmtAttr to associate the descriptor handle with the statement.

下表中的语句特性对应于描述符标头字段。The statement attributes in the following table correspond to descriptor header fields.

语句特性Statement attribute 标头字段Header field Desc.Desc.
SQL_ATTR_PARAM_BIND_OFFSET_PTRSQL_ATTR_PARAM_BIND_OFFSET_PTR SQL_DESC_BIND_OFFSET_PTRSQL_DESC_BIND_OFFSET_PTR APDAPD
SQL_ATTR_PARAM_BIND_TYPESQL_ATTR_PARAM_BIND_TYPE SQL_DESC_BIND_TYPESQL_DESC_BIND_TYPE APDAPD
SQL_ATTR_PARAM_OPERATION_PTRSQL_ATTR_PARAM_OPERATION_PTR SQL_DESC_ARRAY_STATUS_PTRSQL_DESC_ARRAY_STATUS_PTR APDAPD
SQL_ATTR_PARAM_STATUS_PTRSQL_ATTR_PARAM_STATUS_PTR SQL_DESC_ARRAY_STATUS_PTRSQL_DESC_ARRAY_STATUS_PTR IPDIPD
SQL_ATTR_PARAMS_PROCESSED_PTRSQL_ATTR_PARAMS_PROCESSED_PTR SQL_DESC_ROWS_PROCESSED_PTRSQL_DESC_ROWS_PROCESSED_PTR IPDIPD
SQL_ATTR_PARAMSET_SIZESQL_ATTR_PARAMSET_SIZE SQL_DESC_ARRAY_SIZESQL_DESC_ARRAY_SIZE APDAPD
SQL_ATTR_ROW_ARRAY_SIZESQL_ATTR_ROW_ARRAY_SIZE SQL_DESC_ARRAY_SIZESQL_DESC_ARRAY_SIZE ARDARD
SQL_ATTR_ROW_BIND_OFFSET_PTRSQL_ATTR_ROW_BIND_OFFSET_PTR SQL_DESC_BIND_OFFSET_PTRSQL_DESC_BIND_OFFSET_PTR ARDARD
SQL_ATTR_ROW_BIND_TYPESQL_ATTR_ROW_BIND_TYPE SQL_DESC_BIND_TYPESQL_DESC_BIND_TYPE ARDARD
SQL_ATTR_ROW_OPERATION_PTRSQL_ATTR_ROW_OPERATION_PTR SQL_DESC_ARRAY_STATUS_PTRSQL_DESC_ARRAY_STATUS_PTR ARDARD
SQL_ATTR_ROW_STATUS_PTRSQL_ATTR_ROW_STATUS_PTR SQL_DESC_ARRAY_STATUS_PTRSQL_DESC_ARRAY_STATUS_PTR IRDIRD
SQL_ATTR_ROWS_FETCHED_PTRSQL_ATTR_ROWS_FETCHED_PTR SQL_DESC_ROWS_PROCESSED_PTRSQL_DESC_ROWS_PROCESSED_PTR IRDIRD

语句属性Statement Attributes

下表显示了当前定义的属性及其引入的 ODBC 版本。预计,驱动程序会定义更多的属性以利用不同的数据源。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 attributes will be defined by drivers to take advantage of different data sources. ODBC 保留了一系列属性;驱动程序开发人员必须在开放组中保留其自己的特定于驱动程序的使用值。A range of attributes is reserved by ODBC; driver developers must reserve values for their own driver-specific use from Open Group. 有关详细信息,请参阅驱动程序特定的数据类型、描述符类型、信息类型、诊断类型和属性For more information, see Driver-Specific Data Types, Descriptor Types, Information Types, Diagnostic Types, and Attributes.

AttributeAttribute 将 valueptr内容ValuePtr contents
SQL_ATTR_APP_PARAM_DESC (ODBC 3.0)SQL_ATTR_APP_PARAM_DESC (ODBC 3.0) 对语句句柄上的SQLExecuteSQLExecDirect的后续调用的 APD 的句柄。The handle to the APD for subsequent calls to SQLExecute and SQLExecDirect on the statement handle. 此属性的初始值是最初分配语句时隐式分配的说明符。The initial value of this attribute is the descriptor implicitly allocated when the statement was initially allocated. 如果此特性的值设置为 SQL_NULL_DESC 或最初为描述符分配的句柄,则以前与语句句柄关联的显式分配的 APD 句柄与该句柄关联,并且语句句柄恢复到隐式分配的 APD 句柄。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)SQL_ATTR_APP_ROW_DESC (ODBC 3.0) 用于后续语句句柄上的 ARD 的句柄。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. 如果此特性的值设置为 SQL_NULL_DESC 或最初为描述符分配的句柄,则以前与语句句柄关联的显式分配的 ARD 句柄与该句柄关联,并且语句句柄恢复到隐式分配的 ARD 句柄。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)SQL_ATTR_ASYNC_ENABLE (ODBC 1.0) 一个 SQLULEN 生成值,该值指定是否异步执行用指定语句调用的函数:A SQLULEN value that specifies whether a function called with the specified statement is executed asynchronously:

SQL_ASYNC_ENABLE_OFF = Disable 语句级别的异步执行支持(默认值)。SQL_ASYNC_ENABLE_OFF = Disable statement level asynchronous execution support (the default).

SQL_ASYNC_ENABLE_ON = Enable 语句级别的异步执行支持。SQL_ASYNC_ENABLE_ON = Enable statement level asynchronous execution support.

有关详细信息,请参阅异步执行(轮询方法)For more information, see Asynchronous Execution (Polling Method).

对于具有语句级别异步执行支持的驱动程序,语句属性 SQL_ATTR_ASYNC_ENABLE 为只读。For drivers with statement 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.

当 SQL_ASYNC_MODE InfoType返回 SQL_AM_CONNECTION 返回 SQLSTATE HYC00 (未实现可选功能)时,调用SQLSetStmtAttr以设置 SQL_ATTR_ASYNC_ENABLE。Calling SQLSetStmtAttr to set SQL_ATTR_ASYNC_ENABLE when the SQL_ASYNC_MODE InfoType returns SQL_AM_CONNECTION returns SQLSTATE HYC00 (Optional feature not implemented). 有关详细信息,请参阅SQLSetConnectAttr 函数For more information, see SQLSetConnectAttr Function for more information.
SQL_ATTR_ASYNC_STMT_EVENT (ODBC 3.8)SQL_ATTR_ASYNC_STMT_EVENT (ODBC 3.8) 作为事件句柄的 SQLPOINTER 值。A SQLPOINTER value that is an event handle.

异步函数的完成通知是通过调用SQLSetStmtAttr来设置SQL_ATTR_ASYNC_STMT_EVENT特性并指定事件句柄而启用的。Notification of completion of asynchronous functions is enabled by calling SQLSetStmtAttr to set the SQL_ATTR_ASYNC_STMT_EVENT attribute and specify the event handle.
SQL_ATTR_ASYNC_STMT_PCALLBACK (ODBC 3.8)SQL_ATTR_ASYNC_STMT_PCALLBACK (ODBC 3.8) 异步回调函数的 SQLPOINTER。A SQLPOINTER to the asynchronous callback function.

只有驱动程序管理器才能使用此属性调用驱动程序的SQLSetStmtAttr函数。Only the Driver Manager can call a driver's SQLSetStmtAttr function with this attribute.
SQL_ATTR_ASYNC_STMT_PCONTEXT (ODBC 3.8)SQL_ATTR_ASYNC_STMT_PCONTEXT (ODBC 3.8) 上下文结构的 SQLPOINTERA SQLPOINTER to the context structure

只有驱动程序管理器才能使用此属性调用驱动程序的SQLSetStmtAttr函数。Only the Driver Manager can call a driver's SQLSetStmtAttr function with this attribute.
SQL_ATTR_CONCURRENCY (ODBC 2.0)SQL_ATTR_CONCURRENCY (ODBC 2.0) 指定游标并发的 SQLULEN 生成值:An SQLULEN value that specifies the cursor concurrency:

SQL_CONCUR_READ_ONLY = 游标是只读的。SQL_CONCUR_READ_ONLY = Cursor is read-only. 不允许更新。No updates are allowed.

SQL_CONCUR_LOCK = 游标使用足以确保行可更新的最低锁定级别。SQL_CONCUR_LOCK = Cursor uses the lowest level of locking sufficient to ensure that the row can be updated.

SQL_CONCUR_ROWVER = 游标使用乐观并发控制,比较行版本(如 SQLBase ROWID 或 Sybase TIMESTAMP)。SQL_CONCUR_ROWVER = Cursor uses optimistic concurrency control, comparing row versions such as SQLBase ROWID or Sybase TIMESTAMP.

SQL_CONCUR_VALUES = 游标使用乐观并发控制,比较值。SQL_CONCUR_VALUES = Cursor uses optimistic concurrency control, comparing values.

SQL_ATTR_CONCURRENCY 的默认值为 SQL_CONCUR_READ_ONLY。The default value for SQL_ATTR_CONCURRENCY is SQL_CONCUR_READ_ONLY.

不能为打开的游标指定此属性。This attribute cannot be specified for an open cursor. 有关详细信息,请参阅并发类型For more information, see Concurrency Types.

如果 SQL_ATTR_CURSOR_TYPE特性更改为不支持 SQL_ATTR_CONCURRENCY 的当前值的类型,则在执行时将更改 SQL_ATTR_CONCURRENCY 的值,并在调用SQLExecDirectSQLPrepare时发出警告。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 SQLExecDirect or SQLPrepare is called.

如果驱动程序支持SELECT FOR UPDATE语句,并且在 SQL_ATTR_CONCURRENCY 的值设置为 SQL_CONCUR_READ_ONLY 时执行此类语句,则将返回错误。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. 如果 SQL_ATTR_CONCURRENCY 的值更改为驱动程序为某些 SQL_ATTR_CURSOR_TYPE 值(而不是 SQL_ATTR_CURSOR_TYPE 的当前值)所支持的值,则在执行时将更改 SQL_ATTR_CURSOR_TYPE 的值,并在调用SQLExecDirectSQLPREPARE时发出 SQLSTATE 01S02 (选项值已更改)。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 SQLExecDirect or SQLPrepare is called.

如果数据源不支持指定的并发,则驱动程序将替换不同的并发,并返回 SQLSTATE 01S02 (选项值已更改)。If the specified concurrency is not supported by the data source, the driver substitutes a different concurrency and returns SQLSTATE 01S02 (Option value changed). 对于 SQL_CONCUR_VALUES,驱动程序将替换 SQL_CONCUR_ROWVER,反之亦然。For SQL_CONCUR_VALUES, the driver substitutes SQL_CONCUR_ROWVER, and vice versa. 对于 SQL_CONCUR_LOCK,驱动程序按顺序替换 SQL_CONCUR_ROWVER 或 SQL_CONCUR_VALUES。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.

有关 SQL_ATTR_CONCURRENCY 和其他游标属性之间的关系的详细信息,请参阅Cursor 特性和游标类型For more information about the relationship between SQL_ATTR_CONCURRENCY and the other cursor attributes, see Cursor Characteristics and Cursor Type.
SQL_ATTR_CURSOR_SCROLLABLE (ODBC 3.0)SQL_ATTR_CURSOR_SCROLLABLE (ODBC 3.0) 指定应用程序所需的支持级别的 SQLULEN 生成值。An SQLULEN value that specifies the level of support that the application requires. 设置此属性将影响对SQLExecDirectSQLExecute的后续调用。Setting this attribute affects subsequent calls to SQLExecDirect and SQLExecute.

SQL_NONSCROLLABLE = 语句句柄上不需要可滚动游标。SQL_NONSCROLLABLE = Scrollable cursors are not required on the statement handle. 如果应用程序在此句柄上调用SQLFetchScroll ,则唯一的有效值为FetchOrientation SQL_FETCH_NEXT。If the application calls SQLFetchScroll on this handle, the only valid value of FetchOrientation is SQL_FETCH_NEXT. 这是默认值。This is the default.

SQL_SCROLLABLE = 语句句柄上需要可滚动游标。SQL_SCROLLABLE = Scrollable cursors are required on the statement handle. 在调用SQLFetchScroll时,应用程序可以指定任何有效值为FetchOrientation,从而实现除顺序模式之外的其他模式下的游标定位。When calling SQLFetchScroll, the application may specify any valid value of FetchOrientation, achieving cursor positioning in modes other than the sequential mode.

有关可滚动游标的详细信息,请参阅可滚动游标For more information about scrollable cursors, see Scrollable Cursors. 有关 SQL_ATTR_CURSOR_SCROLLABLE 和其他游标属性之间的关系的详细信息,请参阅Cursor 特性和游标类型For more information about the relationship between SQL_ATTR_CURSOR_SCROLLABLE and the other cursor attributes, see Cursor Characteristics and Cursor Type
SQL_ATTR_CURSOR_SENSITIVITY (ODBC 3.0)SQL_ATTR_CURSOR_SENSITIVITY (ODBC 3.0) 一个 SQLULEN 生成值,指定语句句柄上的游标是否会使另一个游标对结果集所做的更改可见。An SQLULEN value that specifies whether cursors on the statement handle make visible the changes made to a result set by another cursor. 设置此属性将影响对SQLExecDirectSQLExecute的后续调用。Setting this attribute affects subsequent calls to SQLExecDirect and SQLExecute. 应用程序可以读取此属性的值,以获取其初始状态或它在应用程序最近设置的状态。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 = 未指定游标类型是什么,语句句柄上的游标是否会使另一个游标对结果集所做的更改可见。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 = 语句句柄上的所有游标都显示结果集,而不反映任何其他游标对其所做的任何更改。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 = 语句句柄上的所有游标都使另一个游标对结果集进行的所有更改都可见。SQL_SENSITIVE = All cursors on the statement handle make visible all changes made to a result set by another cursor.

有关 SQL_ATTR_CURSOR_SENSITIVITY 和其他游标属性之间的关系的详细信息,请参阅Cursor 特性和游标类型For more information about the relationship between SQL_ATTR_CURSOR_SENSITIVITY and the other cursor attributes, see Cursor Characteristics and Cursor Type.
SQL_ATTR_CURSOR_TYPE (ODBC 2.0)SQL_ATTR_CURSOR_TYPE (ODBC 2.0) 指定游标类型的 SQLULEN 生成值:An SQLULEN value that specifies the cursor type:

SQL_CURSOR_FORWARD_ONLY = 游标只向前滚动。SQL_CURSOR_FORWARD_ONLY = The cursor only scrolls forward.

SQL_CURSOR_STATIC = 结果集中的数据是静态的。SQL_CURSOR_STATIC = The data in the result set is static.

SQL_CURSOR_KEYSET_DRIVEN = 驱动程序保存并使用 SQL_ATTR_KEYSET_SIZE 语句特性中指定的行数的键。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 = 驱动程序只保存行集中的行并使用这些行的键。SQL_CURSOR_DYNAMIC = The driver saves and uses only the keys for the rows in the rowset.

默认值为 SQL_CURSOR_FORWARD_ONLY。The default value is SQL_CURSOR_FORWARD_ONLY. 在准备好 SQL 语句后,不能指定此属性。This attribute cannot be specified after the SQL statement has been prepared.

如果数据源不支持指定的游标类型,则驱动程序将替换不同的游标类型并返回 SQLSTATE 01S02 (选项值已更改)。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.

有关可滚动游标类型的详细信息,请参阅可滚动游标类型For more information about scrollable cursor types, see Scrollable Cursor Types. 有关 SQL_ATTR_CURSOR_TYPE 和其他游标属性之间的关系的详细信息,请参阅Cursor 特性和游标类型For more information about the relationship between SQL_ATTR_CURSOR_TYPE and the other cursor attributes, see Cursor Characteristics and Cursor Type.
SQL_ATTR_ENABLE_AUTO_IPD (ODBC 3.0)SQL_ATTR_ENABLE_AUTO_IPD (ODBC 3.0) 一个 SQLULEN 生成值,该值指定是否执行 IPD 的自动填充:An SQLULEN value that specifies whether automatic population of the IPD is performed:

SQL_TRUE = 在调用SQLPrepare后启用 IPD 的自动填充。SQL_TRUE = Turns on automatic population of the IPD after a call to SQLPrepare. SQL_FALSE = 在调用SQLPrepare后关闭 IPD 的自动填充。SQL_FALSE = Turns off automatic population of the IPD after a call to SQLPrepare. (如果支持,应用程序仍可以通过调用SQLDescribeParam来获取 IPD 字段信息。)SQL_FALSE 语句特性 SQL_ATTR_ENABLE_AUTO_IPD 的默认值。(An application can still obtain IPD field information by calling SQLDescribeParam, if supported.) The default value of the statement attribute SQL_ATTR_ENABLE_AUTO_IPD is SQL_FALSE. 有关详细信息,请参阅IPD 的自动填充For more information, see Automatic Population of the IPD.
SQL_ATTR_FETCH_BOOKMARK_PTR (ODBC 3.0)SQL_ATTR_FETCH_BOOKMARK_PTR (ODBC 3.0) 指向二进制*书签值的 SQLLEN。A SQLLEN * that points to a binary bookmark value. 当调用SQLFetchScroll等于 SQL_FETCH_BOOKMARK 的fFetchOrientation时,驱动程序将从此字段选取书签值。When SQLFetchScroll is called with fFetchOrientation equal to SQL_FETCH_BOOKMARK, the driver picks up the bookmark value from this field. 此字段默认为 null 指针。This field defaults to a null pointer. 有关详细信息,请参阅按书签滚动For more information, see Scrolling by Bookmark.

此字段指向的值不用于按书签删除、按书签更新或在SQLBulkOperations中通过书签操作提取,后者使用在行集缓冲区中缓存的书签。The value pointed to by this field is not used for delete by bookmark, update by bookmark, or fetch by bookmark operations in SQLBulkOperations, which use bookmarks cached in rowset buffers.
SQL_ATTR_IMP_PARAM_DESC (ODBC 3.0)SQL_ATTR_IMP_PARAM_DESC (ODBC 3.0) IPD 的句柄。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.

此属性可通过调用SQLGetStmtAttr进行检索,但不能通过调用SQLSetStmtAttr进行设置。This attribute can be retrieved by a call to SQLGetStmtAttr but not set by a call to SQLSetStmtAttr.
SQL_ATTR_IMP_ROW_DESC (ODBC 3.0)SQL_ATTR_IMP_ROW_DESC (ODBC 3.0) IRD 的句柄。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.

此属性可通过调用SQLGetStmtAttr进行检索,但不能通过调用SQLSetStmtAttr进行设置。This attribute can be retrieved by a call to SQLGetStmtAttr but not set by a call to SQLSetStmtAttr.
SQL_ATTR_KEYSET_SIZE (ODBC 2.0)SQL_ATTR_KEYSET_SIZE (ODBC 2.0) 指定由键集驱动的游标的键集中的行数的 SQLULEN 生成。An SQLULEN that specifies the number of rows in the keyset for a keyset-driven cursor. 如果键集大小为0(默认值),则游标是完全键集驱动的。If the keyset size is 0 (the default), the cursor is fully keyset-driven. 如果键集大小大于0,则游标将被混合(键集在键集内并在键集外动态)。If the keyset size is greater than 0, the cursor is mixed (keyset-driven within the keyset and dynamic outside of the keyset). 默认键集大小为0。The default keyset size is 0. 有关由键集驱动的游标的详细信息,请参阅由键集驱动的游标For more information about keyset-driven cursors, see Keyset-Driven Cursors.

如果指定的大小超过最大键集大小,则驱动程序将替换该大小并返回 SQLSTATE 01S02 (选项值已更改)。If the specified size exceeds the maximum keyset size, the driver substitutes that size and returns SQLSTATE 01S02 (Option value changed).

如果键集大小大于0且小于行集大小,则SQLFetchSQLFetchScroll将返回错误。SQLFetch or SQLFetchScroll returns an error if the keyset size is greater than 0 and less than the rowset size.
SQL_ATTR_MAX_LENGTH (ODBC 1.0)SQL_ATTR_MAX_LENGTH (ODBC 1.0) 一个 SQLULEN 生成值,指定驱动程序从字符列或二进制列返回的最大数据量。An SQLULEN value that specifies the maximum amount of data that the driver returns from a character or binary column. 如果将 valueptr小于可用数据的长度,则SQLFetchSQLGetData将截断数据并返回 SQL_SUCCESS。If ValuePtr is less than the length of the available data, SQLFetch or SQLGetData truncates the data and returns SQL_SUCCESS. 如果将 valueptr为0(默认值),则驱动程序将尝试返回所有可用的数据。If ValuePtr is 0 (the default), the driver attempts to return all available data.

如果指定的长度小于数据源可以返回的最小数据量或大于数据源可以返回的最大数据量,则驱动程序将替换该值并返回 SQLSTATE 01S02 (选项值已更改)。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).

可以在打开的游标上设置此属性的值;但是,该设置可能不会立即生效,在这种情况下,驱动程序将返回 SQLSTATE 01S02 (选项值已更改)并将该属性重置为其原始值。The value of this attribute can be set on an open cursor; however, the setting might 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 be supported only when the data source (as opposed to the driver) in a multiple-tier driver can implement it. 应用程序不应使用此机制来截断数据;若要截断接收的数据,应用程序应在SQLBindColSQLGetDataBufferLength参数中指定最大缓冲区长度。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 SQLBindCol or SQLGetData.
SQL_ATTR_MAX_ROWS (ODBC 1.0)SQL_ATTR_MAX_ROWS (ODBC 1.0) 与为SELECT语句返回到应用程序的最大行数对应的 sqlulen 生成值。An SQLULEN value corresponding to the maximum number of rows to return to the application for a SELECT statement. 如果*将 valueptr等于0(默认值),则驱动程序将返回所有行。If *ValuePtr equals 0 (the default), the driver returns all rows.

此属性旨在减少网络流量。This attribute is intended to reduce network traffic. 从概念上讲,此方法在创建结果集时应用,并将结果集限制为第一将 valueptr行。Conceptually, it is applied when the result set is created and limits the result set to the first ValuePtr rows. 如果结果集中的行数大于将 valueptr,则结果集将被截断。If the number of rows in the result set is greater than ValuePtr, the result set is truncated.

SQL_ATTR_MAX_ROWS 适用于语句中的所有结果集,包括目录函数返回的结果集。SQL_ATTR_MAX_ROWS applies to all result sets on the Statement, including those returned by catalog functions. SQL_ATTR_MAX_ROWS 为游标行计数的值建立最大值。SQL_ATTR_MAX_ROWS establishes a maximum for the value of the cursor row count.

如果无法保证正确实现 SQL_ATTR_MAX_ROWS,驱动程序不应模拟SQLFetchSQLFetchScroll的 SQL_ATTR_MAX_ROWS 行为(如果无法在数据源中实现结果集大小限制)。A driver should not emulate SQL_ATTR_MAX_ROWS behavior for SQLFetch or SQLFetchScroll (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.

它是由驱动程序定义的,无论 SQL_ATTR_MAX_ROWS 应用于 SELECT 语句以外的语句(如目录函数)。It is driver-defined whether SQL_ATTR_MAX_ROWS applies to statements other than SELECT statements (such as catalog functions).

可以在打开的游标上设置此属性的值;但是,该设置可能不会立即生效,在这种情况下,驱动程序将返回 SQLSTATE 01S02 (选项值已更改)并将该属性重置为其原始值。The value of this attribute can be set on an open cursor; however, the setting might 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)SQL_ATTR_METADATA_ID (ODBC 3.0) 一个 SQLULEN 生成值,确定如何处理目录函数的字符串参数。An SQLULEN value that determines how the string arguments of catalog functions are treated.

如果 SQL_TRUE,则将目录函数的字符串参数作为标识符处理。If SQL_TRUE, the string argument of catalog functions are treated as identifiers. 这种情况并不重要。The case is not significant. 对于 nondelimited 字符串,驱动程序将删除任何尾随空格,并将该字符串折叠为大写。For nondelimited 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. 如果其中一个参数设置为 null 指针,则该函数将返回 SQL_ERROR 和 SQLSTATE HY009 (null 指针的使用无效)。If one of these arguments is set to a null pointer, the function returns SQL_ERROR and SQLSTATE HY009 (Invalid use of null pointer).

如果 SQL_FALSE,则不会将目录函数的字符串自变量作为标识符处理。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.

默认值为 SQL_FALSE。The default value is SQL_FALSE.

使用值列表的SQLTablesTableType参数不受此特性的影响。The TableType argument of SQLTables, which takes a list of values, is not affected by this attribute.

还可以对连接级别设置 SQL_ATTR_METADATA_ID。SQL_ATTR_METADATA_ID can also be set on the connection level. (它和 SQL_ATTR_ASYNC_ENABLE 是也是连接属性的唯一语句特性。)(It and SQL_ATTR_ASYNC_ENABLE are the only statement attributes that are also connection attributes.)

有关详细信息,请参阅目录函数中的参数For more information, see Arguments in Catalog Functions.
SQL_ATTR_NOSCAN (ODBC 1.0)SQL_ATTR_NOSCAN (ODBC 1.0) 一个 SQLULEN 生成值,该值指示驱动程序是否应扫描 SQL 字符串中的转义序列:An SQLULEN value that indicates whether the driver should scan SQL strings for escape sequences:

SQL_NOSCAN_OFF = 驱动程序扫描 SQL 字符串是否有转义序列(默认值)。SQL_NOSCAN_OFF = The driver scans SQL strings for escape sequences (the default).

SQL_NOSCAN_ON = 驱动程序不扫描 SQL 字符串是否有转义序列。SQL_NOSCAN_ON = The driver does not scan SQL strings for escape sequences. 相反,驱动程序将语句直接发送到数据源。Instead, the driver sends the statement directly to the data source.

有关详细信息,请参阅ODBC 中的转义序列For more information, see Escape Sequences in ODBC.
SQL_ATTR_PARAM_BIND_OFFSET_PTR (ODBC 3.0)SQL_ATTR_PARAM_BIND_OFFSET_PTR (ODBC 3.0) 一个 SQLULEN 生成 * 值,它指向添加到指针的偏移量,以更改动态参数的绑定。An SQLULEN * value that points to an offset added to pointers to change binding of dynamic parameters. 如果此字段为非 null,则驱动程序将取消引用指针,将取消引用的值添加到描述符记录中的每个延迟字段(SQL_DESC_DATA_PTR、SQL_DESC_INDICATOR_PTR 和 SQL_DESC_OCTET_LENGTH_PTR),并使用新的指针值绑定时。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. 默认情况下,它设置为 null。It is set to null by default.

绑定偏移量始终直接添加到 SQL_DESC_DATA_PTR、SQL_DESC_INDICATOR_PTR 和 SQL_DESC_OCTET_LENGTH_PTR 字段。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.

有关详细信息,请参阅参数绑定偏移量For more information, see Parameter Binding Offsets.

设置此语句特性将在 APD 标头中设置 SQL_DESC_BIND_OFFSET_PTR 字段。Setting this statement attribute sets the SQL_DESC_BIND_OFFSET_PTR field in the APD header.
SQL_ATTR_PARAM_BIND_TYPE (ODBC 3.0)SQL_ATTR_PARAM_BIND_TYPE (ODBC 3.0) 一个 SQLULEN 生成值,指示用于动态参数的绑定方向。An SQLULEN value that indicates the binding orientation to be used for dynamic parameters.

此字段设置为 SQL_PARAM_BIND_BY_COLUMN (默认值)以选择按列绑定。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. 在 ANSI C 中使用sizeof运算符时,此行为是保证的。When using the sizeof operator in ANSI C, this behavior is guaranteed.

有关详细信息,请参阅绑定参数数组For more information, see Binding Arrays of Parameters.

设置此语句特性将在 APD 标头中设置 SQL_DESC_ BIND_TYPE 字段。Setting this statement attribute sets the SQL_DESC_ BIND_TYPE field in the APD header.
SQL_ATTR_PARAM_OPERATION_PTR (ODBC 3.0)SQL_ATTR_PARAM_OPERATION_PTR (ODBC 3.0) 一个 SQLUSMALLINT *值,该值指向一个 SQLUSMALLINT 值数组,这些值用于在 SQL 语句执行过程中忽略参数。An SQLUSMALLINT * value that points to an array of SQLUSMALLINT values used to ignore a parameter during execution of an SQL statement. 每个值都设置为 SQL_PARAM_PROCEED (对于要执行的参数)或 SQL_PARAM_IGNORE (表示要忽略的参数)。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).

可以在处理过程中忽略一组参数,方法是在 APD 中通过将状态值设置为 SQL_PARAM_IGNORE SQL_DESC_ARRAY_STATUS_PTR。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. 如果将参数的 status 值设置为 SQL_PARAM_PROCEED 或数组中没有元素,则会处理一组参数。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.

此语句属性可以设置为 null 指针,在这种情况下,驱动程序不返回参数状态值。This statement attribute can be set to a null pointer, in which case the driver does not return parameter status values. 此属性可随时设置,但在下一次调用SQLExecDirectSQLExecute之前,不会使用新值。This attribute can be set at any time, but the new value is not used until the next time SQLExecDirect or SQLExecute is called.

如果没有绑定参数,则忽略此属性。This attribute is ignored when there is no bound parameter.

有关详细信息,请参阅使用参数数组For more information, see Using Arrays of Parameters.

设置此语句特性将在 APD 标头中设置 SQL_DESC_ARRAY_STATUS_PTR 字段。Setting this statement attribute sets the SQL_DESC_ARRAY_STATUS_PTR field in the APD header.
SQL_ATTR_PARAM_STATUS_PTR (ODBC 3.0)SQL_ATTR_PARAM_STATUS_PTR (ODBC 3.0) 一个 SQLUSMALLINT *值,该值指向在调用SQLExecuteSQLExecDirect后包含参数值的每一行的状态信息的 SQLUSMALLINT 值的数组。An SQLUSMALLINT * value that points to an array of SQLUSMALLINT values containing status information for each row of parameter values after a call to SQLExecute or SQLExecDirect. 仅当 PARAMSET_SIZE 大于1时,此字段才是必需的。This field is required only if PARAMSET_SIZE is greater than 1.

状态值可以包含以下值:The status values can contain the following values:

SQL_PARAM_SUCCESS:已成功为此参数集执行 SQL 语句。SQL_PARAM_SUCCESS: The SQL statement was successfully executed for this set of parameters.

SQL_PARAM_SUCCESS_WITH_INFO:已成功为此参数集执行 SQL 语句;但是,诊断数据结构中提供了警告信息。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:处理此参数集时出错。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:未使用此参数集,这可能是由于某些先前的参数集导致了导致进一步处理终止的错误,或者是因为在指定的数组中为该参数集设置了 SQL_PARAM_IGNORE SQL_ATTR_PARAM_OPERATION_PTR。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:驱动程序将参数数组视为单个单元,因此不会生成此级别的错误信息。SQL_PARAM_DIAG_UNAVAILABLE: The driver treats arrays of parameters as a monolithic unit and so does not generate this level of error information.

此语句属性可以设置为 null 指针,在这种情况下,驱动程序不返回参数状态值。This statement attribute can be set to a null pointer, in which case the driver does not return parameter status values. 此属性可随时设置,但在下一次调用SQLExecuteSQLExecDirect之前,不会使用新值。This attribute can be set at any time, but the new value is not used until the next time SQLExecute or SQLExecDirect is called. 请注意,设置此属性会影响驱动程序实现的输出参数行为。Note that setting this attribute can affect the output parameter behavior implemented by the driver.

有关详细信息,请参阅使用参数数组For more information, see Using Arrays of Parameters.

设置此语句属性将设置 IPD 标头中的 "SQL_DESC_ARRAY_STATUS_PTR" 字段。Setting this statement attribute sets the SQL_DESC_ARRAY_STATUS_PTR field in the IPD header.
SQL_ATTR_PARAMS_PROCESSED_PTR (ODBC 3.0)SQL_ATTR_PARAMS_PROCESSED_PTR (ODBC 3.0) 一个 SQLULEN 生成*记录字段,该字段指向一个缓冲区,该缓冲区用于返回已处理的参数集的数目,包括错误集。An SQLULEN * record field that points to a buffer in which to return the number of sets of parameters that have been processed, including error sets. 如果为 null 指针,则不返回任何数字。No number will be returned if this is a null pointer.

设置此语句属性将设置 IPD 标头中的 "SQL_DESC_ROWS_PROCESSED_PTR" 字段。Setting this statement attribute sets the SQL_DESC_ROWS_PROCESSED_PTR field in the IPD header.

如果对SQLExecDirectSQLExecute的调用,而此属性所指向的缓冲区未返回 SQL_SUCCESS 或 SQL_SUCCESS_WITH_INFO,则缓冲区的内容不确定。If the call to SQLExecDirect or SQLExecute 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.

有关详细信息,请参阅使用参数数组For more information, see Using Arrays of Parameters.
SQL_ATTR_PARAMSET_SIZE (ODBC 3.0)SQL_ATTR_PARAMSET_SIZE (ODBC 3.0) 一个 SQLULEN 生成值,该值指定每个参数的值的数目。An SQLULEN value that specifies the number of values for each parameter. 如果 SQL_ATTR_PARAMSET_SIZE 大于1,则将 APD 点 SQL_DESC_DATA_PTR、SQL_DESC_INDICATOR_PTR 和 SQL_DESC_OCTET_LENGTH_PTR 为数组。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.

如果没有绑定参数,则忽略此属性。This attribute is ignored when there is no bound parameter.

有关详细信息,请参阅使用参数数组For more information, see Using Arrays of Parameters.

设置此语句特性将在 APD 标头中设置 SQL_DESC_ARRAY_SIZE 字段。Setting this statement attribute sets the SQL_DESC_ARRAY_SIZE field in the APD header.
SQL_ATTR_QUERY_TIMEOUT (ODBC 1.0)SQL_ATTR_QUERY_TIMEOUT (ODBC 1.0) 与在返回应用程序之前等待 SQL 语句执行的秒数对应的 SQLULEN 生成值。An SQLULEN value corresponding to the number of seconds to wait for an SQL statement to execute before returning to the application. 如果将 valueptr等于0(默认值),则不会超时。If ValuePtr is equal to 0 (default), there is no timeout.

如果指定的超时值超过了数据源中的最大超时值或小于最小超时值,则SQLSetStmtAttr将替换该值并返回 SQLSTATE 01S02 (选项值已更改)。If the specified timeout exceeds the maximum timeout in the data source or is smaller than the minimum timeout, SQLSetStmtAttr substitutes that value and returns SQLSTATE 01S02 (Option value changed).

请注意,如果SELECT语句超时,应用程序无需调用SQLCloseCursor即可重复使用该语句。Note that the application need not call SQLCloseCursor 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)SQL_ATTR_RETRIEVE_DATA (ODBC 2.0) SQLULEN 生成值:An SQLULEN value:

SQL_RD_ON = SQLFetchScroll在 ODBC 3.X 中, SQLFetch在将游标定位到指定位置之后检索数据。SQL_RD_ON = SQLFetchScroll and, in ODBC 3.x, SQLFetch retrieve data after it positions the cursor to the specified location. 这是默认值。This is the default.

SQL_RD_OFF = SQLFetchScroll在 ODBC 3.X 中, SQLFetch不在定位游标后检索数据。SQL_RD_OFF = SQLFetchScroll and, in ODBC 3.x, SQLFetch do not retrieve data after it positions the cursor.

通过将 SQL_RETRIEVE_DATA 设置为 SQL_RD_OFF,应用程序可以验证行是否存在,也可以检索行的书签,而不会产生检索行的开销。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. 有关详细信息,请参阅滚动和提取行For more information, see Scrolling and Fetching Rows.

可以在打开的游标上设置此属性的值;但是,该设置可能不会立即生效,在这种情况下,驱动程序将返回 SQLSTATE 01S02 (选项值已更改)并将该属性重置为其原始值。The value of this attribute can be set on an open cursor; however, the setting might 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)SQL_ATTR_ROW_ARRAY_SIZE (ODBC 3.0) 一个 SQLULEN 生成值,指定每次调用SQLFetchSQLFetchScroll时返回的行数。An SQLULEN value that specifies the number of rows returned by each call to SQLFetch or SQLFetchScroll. 它也是在SQLBulkOperations中批量书签操作中使用的书签数组中的行数。It is also the number of rows in a bookmark array used in a bulk bookmark operation in SQLBulkOperations. 默认值为 1。The default value is 1.

如果指定的行集大小超过了数据源支持的最大行集大小,则驱动程序将替换该值并返回 SQLSTATE 01S02 (选项值已更改)。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).

有关详细信息,请参阅行集大小For more information, see Rowset Size.

设置此语句特性将在 ARD 标头中设置 SQL_DESC_ARRAY_SIZE 字段。Setting this statement attribute sets the SQL_DESC_ARRAY_SIZE field in the ARD header.
SQL_ATTR_ROW_BIND_OFFSET_PTR (ODBC 3.0)SQL_ATTR_ROW_BIND_OFFSET_PTR (ODBC 3.0) 一个 SQLULEN 生成 * 值,它指向添加到指针的偏移量,以更改列数据的绑定。An SQLULEN * value that points to an offset added to pointers to change binding of column data. 如果此字段为非 null,则驱动程序将取消引用指针,将取消引用的值添加到描述符记录中的每个延迟字段(SQL_DESC_DATA_PTR、SQL_DESC_INDICATOR_PTR 和 SQL_DESC_OCTET_LENGTH_PTR),并使用新的指针值绑定时。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. 默认情况下,它设置为 null。It is set to null by default.

设置此语句特性将在 ARD 标头中设置 SQL_DESC_BIND_OFFSET_PTR 字段。Setting this statement attribute sets the SQL_DESC_BIND_OFFSET_PTR field in the ARD header.
SQL_ATTR_ROW_BIND_TYPE (ODBC 1.0)SQL_ATTR_ROW_BIND_TYPE (ODBC 1.0) 一个 SQLULEN 生成值,用于设置在关联语句上调用SQLFetchSQLFetchScroll时使用的绑定方向。An SQLULEN value that sets the binding orientation to be used when SQLFetch or SQLFetchScroll is called on the associated statement. 通过将值设置为 SQL_BIND_BY_COLUMN 来选择按列绑定。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.

如果指定了长度,则它必须包含所有绑定列以及结构或缓冲区的任何填充的空间,以确保当绑定列的地址递增指定的长度时,结果将指向第一列中的同一列的开头e 下一行。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. 在 ANSI C 中将sizeof运算符与结构或联合一起使用时,此行为是保证的。When using the sizeof operator with structures or unions in ANSI C, this behavior is guaranteed.

按列绑定是SQLFetchSQLFetchScroll的默认绑定方向。Column-wise binding is the default binding orientation for SQLFetch and SQLFetchScroll.

有关详细信息,请参阅用于阻止游标的绑定列For more information, see Binding Columns for Use with Block Cursors.

设置此语句特性将在 ARD 标头中设置 SQL_DESC_BIND_TYPE 字段。Setting this statement attribute sets the SQL_DESC_BIND_TYPE field in the ARD header.
SQL_ATTR_ROW_NUMBER (ODBC 2.0)SQL_ATTR_ROW_NUMBER (ODBC 2.0) 一个 SQLULEN 生成值,该值是整个结果集中的当前行数。An SQLULEN value that is the number of the current row in the entire result set. 如果无法确定当前行的数目或没有当前行,则驱动程序将返回0。If the number of the current row cannot be determined or there is no current row, the driver returns 0.

此属性可通过调用SQLGetStmtAttr进行检索,但不能通过调用SQLSetStmtAttr进行设置。This attribute can be retrieved by a call to SQLGetStmtAttr but not set by a call to SQLSetStmtAttr.
SQL_ATTR_ROW_OPERATION_PTR (ODBC 3.0)SQL_ATTR_ROW_OPERATION_PTR (ODBC 3.0) 一个 SQLUSMALLINT *值,该值指向 SQLUSMALLINT 值的数组,这些值用于在使用SQLSetPos时使用的大容量操作中忽略行。An SQLUSMALLINT * value that points to an array of SQLUSMALLINT values used to ignore a row during a bulk operation using SQLSetPos. 每个值都设置为 SQL_ROW_PROCEED (对于要包含在大容量操作中的行)或 SQL_ROW_IGNORE (对于要从大容量操作中排除的行)。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). (在对SQLBulkOperations的调用期间,不能使用此数组忽略行。)(Rows cannot be ignored by using this array during calls to SQLBulkOperations.)

此语句属性可以设置为 null 指针,在这种情况下,驱动程序不返回行状态值。This statement attribute can be set to a null pointer, in which case the driver does not return row status values. 此属性可随时设置,但在下一次调用SQLSetPos之前,不会使用新值。This attribute can be set at any time, but the new value is not used until the next time SQLSetPos is called.

有关详细信息,请参阅通过 SQLSetPos 更新行集中的行通过 SQLSetPos 删除行集中的行For more information, see Updating Rows in the Rowset with SQLSetPos and Deleting Rows in the Rowset with SQLSetPos.

设置此语句特性将在 ARD 中设置 SQL_DESC_ARRAY_STATUS_PTR 字段。Setting this statement attribute sets the SQL_DESC_ARRAY_STATUS_PTR field in the ARD.
SQL_ATTR_ROW_STATUS_PTR (ODBC 3.0)SQL_ATTR_ROW_STATUS_PTR (ODBC 3.0) 一个 SQLUSMALLINT *值,该值指向 SQLUSMALLINT 值的数组,这些值包含调用SQLFetchSQLFetchScroll后的行状态值。An SQLUSMALLINT * value that points to an array of SQLUSMALLINT values containing row status values after a call to SQLFetch or SQLFetchScroll. 数组中的元素数目与行集中的行数相同。The array has as many elements as there are rows in the rowset.

此语句属性可以设置为 null 指针,在这种情况下,驱动程序不返回行状态值。This statement attribute can be set to a null pointer, in which case the driver does not return row status values. 此属性可随时设置,但在下一次调用SQLBulkOperationsSQLFetchSQLFetchScrollSQLSetPos之前,不会使用新值。This attribute can be set at any time, but the new value is not used until the next time SQLBulkOperations, SQLFetch, SQLFetchScroll, or SQLSetPos is called.

有关详细信息,请参阅提取的行数和状态For more information, see Number of Rows Fetched and Status.

设置此语句特性将在 IRD 标头中设置 SQL_DESC_ARRAY_STATUS_PTR 字段。Setting this statement attribute sets the SQL_DESC_ARRAY_STATUS_PTR field in the IRD header.

在对SQLExtendedFetch的调用中,此属性由 ODBC 2.x驱动程序映射到rgbRowStatus数组。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)SQL_ATTR_ROWS_FETCHED_PTR (ODBC 3.0) 一个 SQLULEN 生成*值,它指向一个缓冲区,返回在调用SQLFetchSQLFetchScroll后提取的行数;使用 SQL_REFRESH 的操作参数对SQLSetPos的调用所影响的行数。或由SQLBulkOperations执行的大容量操作影响的行数。An SQLULEN * value that points to a buffer in which to return the number of rows fetched after a call to SQLFetch or SQLFetchScroll; the number of rows affected by a bulk operation performed by a call to SQLSetPos with an Operation argument of SQL_REFRESH; or the number of rows affected by a bulk operation performed by SQLBulkOperations. 此数字包含错误行。This number includes error rows.

有关详细信息,请参阅提取的行数和状态For more information, see Number of Rows Fetched and Status.

设置此语句特性将在 IRD 标头中设置 SQL_DESC_ROWS_PROCESSED_PTR 字段。Setting this statement attribute sets the SQL_DESC_ROWS_PROCESSED_PTR field in the IRD header.

如果对SQLFetchSQLFetchScroll的调用,而此属性所指向的缓冲区未返回 SQL_SUCCESS 或 SQL_SUCCESS_WITH_INFO,则缓冲区的内容不确定。If the call to SQLFetch or SQLFetchScroll 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)SQL_ATTR_SIMULATE_CURSOR (ODBC 2.0) 一个 SQLULEN 生成值,指定模拟定位的 update 和 delete 语句的驱动程序是否保证此类语句仅影响一行。An SQLULEN value that specifies whether drivers that simulate positioned update and delete statements guarantee that such statements affect only one single row.

若要模拟定位的 update 和 delete 语句,大多数驱动程序将构造一个包含WHERE子句的搜索到的updatedelete语句,该语句指定当前行中每列的值。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 can 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 = 驱动程序不保证模拟定位的 update 或 delete 语句仅影响一行;应用程序负责执行此操作。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. 如果语句影响多个行,则SQLExecuteSQLExecDirectSQLSetPos返回 SQLSTATE 01001 (游标操作冲突)。If a statement affects more than one row, SQLExecute, SQLExecDirect, or SQLSetPos returns SQLSTATE 01001 (Cursor operation conflict).

SQL_SC_TRY_UNIQUE = 驱动程序尝试保证模拟定位的 update 或 delete 语句仅影响一行。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. 如果语句影响多个行,则SQLExecuteSQLExecDirectSQLSetPos返回 SQLSTATE 01001 (游标操作冲突)。If a statement affects more than one row, SQLExecute, SQLExecDirect, or SQLSetPos returns SQLSTATE 01001 (Cursor operation conflict).

SQL_SC_UNIQUE = 驱动程序保证模拟定位的 update 或 delete 语句仅影响一行。SQL_SC_UNIQUE = The driver guarantees that simulated positioned update or delete statements affect only one row. 如果驱动程序无法保证给定语句的这种情况,则SQLExecDirectSQLPrepare将返回错误。If the driver cannot guarantee this for a given statement, SQLExecDirect or SQLPrepare returns an error.

如果数据源为定位的 update 和 delete 语句提供本机 SQL 支持并且驱动程序不模拟游标,则当 SQL_SC_UNIQUE 请求 SQL_SIMULATE_CURSOR 时,将返回 SQL_SUCCESS。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_SC_TRY_UNIQUE 或 SQL_SC_NON_UNIQUE,则返回 SQL_SUCCESS_WITH_INFO。SQL_SUCCESS_WITH_INFO is returned if SQL_SC_TRY_UNIQUE or SQL_SC_NON_UNIQUE is requested. 如果数据源提供了 SQL_SC_TRY_UNIQUE 级别的支持,但驱动程序没有,则为 SQL_SC_TRY_UNIQUE 返回 SQL_SUCCESS,并为 SQL_SC_NON_UNIQUE 返回 SQL_SUCCESS_WITH_INFO。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.

如果数据源不支持指定的游标模拟类型,则驱动程序将替换为不同的模拟类型,并返回 SQLSTATE 01S02 (选项值已更改)。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). 对于 SQL_SC_UNIQUE,驱动程序按顺序替换 SQL_SC_TRY_UNIQUE 或 SQL_SC_NON_UNIQUE。For SQL_SC_UNIQUE, the driver substitutes, in order, SQL_SC_TRY_UNIQUE or SQL_SC_NON_UNIQUE. 对于 SQL_SC_TRY_UNIQUE,驱动程序 SQL_SC_NON_UNIQUE 替换。For SQL_SC_TRY_UNIQUE, the driver substitutes SQL_SC_NON_UNIQUE.

默认值为 SQL_SC_UNIQUE。The default is SQL_SC_UNIQUE.

有关详细信息,请参阅模拟定位的 Update 和 Delete 语句For more information, see Simulating Positioned Update and Delete Statements.
SQL_ATTR_USE_BOOKMARKS (ODBC 2.0)SQL_ATTR_USE_BOOKMARKS (ODBC 2.0) 一个 SQLULEN 生成值,该值指定应用程序是否将书签与光标一起使用:An SQLULEN value that specifies whether an application will use bookmarks with a cursor:

SQL_UB_OFF = Off (默认值)SQL_UB_OFF = Off (the default)

SQL_UB_VARIABLE = 应用程序将书签与光标一起使用,并且驱动程序将提供长度可变的书签(如果支持)。SQL_UB_VARIABLE = An application will use bookmarks with a cursor, and the driver will provide variable-length bookmarks if they are supported. ODBC 2.x 中已弃用SQL_UB_FIXED。SQL_UB_FIXED is deprecated in ODBC 3.x. ODBC 2.x 应用程序应始终使用可变长度书签,即使使用的是 odbc 2.x驱动程序(仅支持4个字节的固定长度书签)。ODBC 3.x 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. 使用 ODBC 2.x 驱动程序时,驱动程序管理器会将 SQL_UB_VARIABLE 映射到 SQL_UB_FIXED。When working with an ODBC 2.x driver, the Driver Manager maps SQL_UB_VARIABLE to SQL_UB_FIXED.

若要在游标中使用书签,应用程序必须在打开游标前使用 SQL_UB_VARIABLE 值指定此属性。To use bookmarks with a cursor, the application must specify this attribute with the SQL_UB_VARIABLE value before opening the cursor.

有关详细信息,请参阅检索书签For more information, see Retrieving Bookmarks.

[1] 仅当描述符是实现描述符,而不是应用程序描述符时,才能以异步方式调用这些函数。[1] These functions can be called asynchronously only if the descriptor is an implementation descriptor, not an application descriptor.

请参阅按列绑定和按行绑定See Column-Wise Binding and Row-Wise Binding.

有关以下方面的信息For information about 请参阅See
正在取消语句处理Canceling statement processing SQLCancel 函数SQLCancel Function
返回连接属性的设置Returning the setting of a connection attribute SQLGetConnectAttr 函数SQLGetConnectAttr Function
返回语句特性的设置Returning the setting of a statement attribute SQLGetStmtAttr 函数SQLGetStmtAttr Function
设置连接属性Setting a connection attribute SQLSetConnectAttr 函数SQLSetConnectAttr Function
设置描述符的单个字段Setting a single field of the descriptor SQLSetDescField 函数SQLSetDescField Function

另请参阅See Also

ODBC API 参考 ODBC API Reference
ODBC 头文件ODBC Header Files