SQLFetch 函数SQLFetch Function

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

摘要Summary
SQLFetch从结果集中提取下一个数据行集, 并返回所有绑定列的数据。SQLFetch fetches the next rowset of data from the result set and returns data for all bound columns.

语法Syntax

  
SQLRETURN SQLFetch(  
     SQLHSTMT     StatementHandle);  

参数Arguments

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

返回Returns

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

诊断Diagnostics

SQLFetch返回 SQL_ERROR 或 SQL_SUCCESS_WITH_INFO 时, 可以通过使用SQLGetDiagRec 的 HandleType和 SQL_HANDLE_STMT 的句柄调用StatementHandle 函数来获取关联的 SQLSTATE 值。When SQLFetch returns either SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling SQLGetDiagRec Function with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. 下表列出了通常由SQLFetch返回的 SQLSTATE 值, 并对该函数的上下文中的每个值进行了说明:"(DM)" 表示法位于驱动程序管理器返回的 SQLSTATEs 的说明之前。The following table lists the SQLSTATE values typically returned by SQLFetch 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. 如果对单个列发生错误, 则可以使用 SQL_DIAG_COLUMN_NUMBER 的DiagIdentifier调用SQLGetDiagField , 以确定发生错误的列;可以使用 SQL_DIAG_ROW_NUMBER 的DiagIdentifier调用和SQLGetDiagField来确定包含该列的行。If an error occurs on a single column, SQLGetDiagField can be called with a DiagIdentifier of SQL_DIAG_COLUMN_NUMBER to determine the column the error occurred on; and SQLGetDiagField can be called with a DiagIdentifier of SQL_DIAG_ROW_NUMBER to determine the row that contains that column.

对于可以返回 SQL_SUCCESS_WITH_INFO 或 SQL_ERROR 的所有 SQLSTATEs (除了 01xxx SQLSTATEs), 如果在一个或多个 (但不是全部) 行上发生错误, 则将返回 SQL_SUCCESS_WITH_INFO; 如果发生错误, 则返回多行单行操作。For all those SQLSTATEs that can return SQL_SUCCESS_WITH_INFO or SQL_ERROR (except 01xxx SQLSTATEs), SQL_SUCCESS_WITH_INFO is returned if an error occurs on one or more, but not all, rows of a multirow operation, and SQL_ERROR is returned if an error occurs on a single-row operation.

SQLSTATESQLSTATE ErrorError 描述Description
0100001000 一般警告General warning 驱动程序特定的信息性消息。Driver-specific informational message. (函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
0100401004 字符串数据, 右截断String data, right truncated 为列返回的字符串或二进制数据导致截断非空白字符或非空的二进制数据。String or binary data returned for a column resulted in the truncation of nonblank character or non-NULL binary data. 如果它是一个字符串值, 则它将被右截断。If it was a string value, it was right-truncated.
01S0101S01 行中的错误Error in row 提取一行或多行时出错。An error occurred while fetching one or more rows.

(如果在 ODBC3.x 应用程序使用 odbc2.x 驱动程序时返回此 SQLSTATE, 则可以将其忽略。)(If this SQLSTATE is returned when an ODBC 3 .x application is working with an ODBC 2 .x driver, it can be ignored.)
01S0701S07 小数截断Fractional truncation 为列返回的数据被截断。The data returned for a column was truncated. 对于数值数据类型, 数值的小数部分被截断。For numeric data types, the fractional part of the number was truncated. 对于包含时间部分的时间、时间戳和间隔数据类型, 时间的小数部分将被截断。For time, timestamp, and interval data types that contain a time component, the fractional part of the time was truncated.

(函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
0700607006 受限制的数据类型属性冲突Restricted data type attribute violation 结果集中列的数据值无法转换为SQLBindColTargetType指定的数据类型。The data value of a column in the result set could not be converted to the data type specified by TargetType in SQLBindCol.

列0与 SQL_C_BOOKMARK 的数据类型绑定, SQL_ATTR_USE_BOOKMARKS 语句特性设置为 SQL_UB_VARIABLE。Column 0 was bound with a data type of SQL_C_BOOKMARK, and the SQL_ATTR_USE_BOOKMARKS statement attribute was set to SQL_UB_VARIABLE.

列0与数据类型 SQL_C_VARBOOKMARK 绑定, 而 SQL_ATTR_USE_BOOKMARKS 语句特性未设置为 SQL_UB_VARIABLE。Column 0 was bound with a data type of SQL_C_VARBOOKMARK, and the SQL_ATTR_USE_BOOKMARKS statement attribute was not set to SQL_UB_VARIABLE.
0700907009 描述符索引无效Invalid descriptor index 驱动程序是不支持SQLExtendedFetch的 ODBC2.x 驱动程序, 并且在绑定中为列指定的列号为0。The driver was an ODBC 2 .x driver that does not support SQLExtendedFetch, and a column number specified in the binding for a column was 0.

已绑定列 0, 并且 SQL_ATTR_USE_BOOKMARKS 语句属性设置为 SQL_UB_OFF。Column 0 was bound, and the SQL_ATTR_USE_BOOKMARKS statement attribute was set to SQL_UB_OFF.
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.
2200122001 字符串数据, 右截断String data, right truncated 为列返回的可变长度书签已截断。A variable-length bookmark returned for a column was truncated.
2200222002 需要指示器变量, 但未提供Indicator variable required but not supplied NULL 数据提取到StrLen_or_IndPtr设置的列中, SQLBINDCOL (或 SQL_DESC_INDICATOR_PTR 通过SQLSetDescFieldSQLSetDescRec设置) 为 null 指针。NULL data was fetched into a column whose StrLen_or_IndPtr set by SQLBindCol (or SQL_DESC_INDICATOR_PTR set by SQLSetDescField or SQLSetDescRec) was a null pointer.
2200322003 数值超出范围Numeric value out of range 对于一个或多个绑定列, 将数值返回为数值或字符串, 将导致数字的整个 (而不是小数) 部分被截断。Returning the numeric value as numeric or string for one or more bound columns would have caused the whole (as opposed to fractional) part of the number to be truncated.

有关详细信息, 请参阅附录D:数据类型。For more information, see Converting Data from SQL to C Data Types in Appendix D: Data Types.
2200722007 Datetime 格式无效Invalid datetime format 结果集中的字符列已绑定到日期、时间或时间戳 C 结构, 列中的值分别为无效的日期、时间或时间戳。A character column in the result set was bound to a date, time, or timestamp C structure, and a value in the column was, respectively, an invalid date, time, or timestamp.
2201222012 被零除Division by zero 返回了算术表达式中的值, 从而导致被零除。A value from an arithmetic expression was returned, which resulted in division by zero.
2201522015 间隔字段溢出Interval field overflow 从精确数值或间隔 SQL 类型赋值到 interval C 类型会导致前导字段的有效位丢失。Assigning from an exact numeric or interval SQL type to an interval C type caused a loss of significant digits in the leading field.

将数据提取到 interval C 类型时, interval C 类型中没有 SQL 类型的值的表示形式。When fetching data to an interval C type, there was no representation of the value of the SQL type in the interval C type.
2201822018 转换规范的字符值无效Invalid character value for cast specification 结果集中的字符列已绑定到字符 C 缓冲区, 列包含的字符在缓冲区的字符集中没有表示形式。A character column in the result set was bound to a character C buffer, and the column contained a character for which there was no representation in the character set of the buffer.

C 类型是精确或近似数字、日期时间或间隔数据类型;列的 SQL 类型是字符数据类型;列中的值不是绑定 C 类型的有效文本。The C type was an exact or approximate numeric, a datetime, or an interval data type; the SQL type of the column was a character data type; and the value in the column was not a valid literal of the bound C type.
2400024000 无效的游标状态Invalid cursor state StatementHandle处于已执行状态, 但没有与StatementHandle关联的结果集。The StatementHandle was in an executed state but no result set was associated with the StatementHandle.
4000140001 序列化失败Serialization failure 执行提取的事务已终止, 以防止死锁。The transaction in which the fetch was executed was terminated to prevent deadlock.
4000340003 语句完成情况未知Statement completion unknown 在执行此函数的过程中关联的连接失败, 无法确定事务的状态。The associated connection failed during the execution of this function, and the state of the transaction cannot be determined.
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 that is required to support execution or completion of the function.
HY008HY008 操作已取消Operation canceled 已为StatementHandle启用异步处理。Asynchronous processing was enabled for the StatementHandle. 调用SQLFetch函数, 并在其完成执行之前, 对StatementHandle调用SQLCancelSQLCancelHandleThe SQLFetch function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle. 然后, 在StatementHandle上再次调用SQLFetch函数。Then the SQLFetch function was called again on the StatementHandle.

或者, 在执行完SQLFetch函数之前, 从多线程应用程序中的另一个线程调用StatementHandle上的SQLCancelSQLCancelHandleOr, the SQLFetch function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle from a different thread in a multithread application.
HY010HY010 函数序列错误Function sequence error (DM) 为与StatementHandle关联的连接句柄调用了异步执行的函数。(DM) An asynchronously executing function was called for the connection handle that is associated with the StatementHandle. 调用SQLFetch函数时, 此异步函数仍在执行。This asynchronous function was still executing when the SQLFetch function was called.

(DM) 为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) The specified StatementHandle was not in an executed state. 调用函数时, 无需先调用SQLExecDirectSQLExecute或 catalog 函数。The function was called without first calling SQLExecDirect, SQLExecute or a catalog function.

(DM) 为StatementHandle调用了异步执行的函数 (而不是此函数), 并且在调用此函数时仍在执行。(DM) An asynchronously executing function (not this one) 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.

(DM) 在调用SQLExtendedFetch后, 调用了StatementHandle SQLFETCH , 并调用了 SQL_CLOSE 选项SQLFreeStmt(DM) SQLFetch was called for the StatementHandle after SQLExtendedFetch was called and before SQLFreeStmt with the SQL_CLOSE option was called.
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.
HY090HY090 字符串或缓冲区长度无效Invalid string or buffer length SQL_ATTR_USE_BOOKMARK 语句特性设置为 SQL_UB_VARIABLE, 而列0绑定到的缓冲区的长度不等于此结果集的书签的最大长度。The SQL_ATTR_USE_BOOKMARK statement attribute was set to SQL_UB_VARIABLE, and column 0 was bound to a buffer whose length was not equal to the maximum length for the bookmark for this result set. (此长度在 IRD 的 SQL_DESC_OCTET_LENGTH 字段中提供, 可以通过调用SQLDescribeColSQLColAttributeSQLGetDescField获取。)(This length is available in the SQL_DESC_OCTET_LENGTH field of the IRD and can be obtained by calling SQLDescribeCol, SQLColAttribute, or SQLGetDescField.)
HY107HY107 行值超出范围Row value out of range 用 SQL_ATTR_CURSOR_TYPE 语句特性指定的值为 SQL_CURSOR_KEYSET_DRIVEN, 但通过 SQL_ATTR_KEYSET_SIZE 语句特性指定的值大于0且小于用 SQL_ATTR_ROW_ARRAY_ 指定的值SIZE 语句特性。The value specified with the SQL_ATTR_CURSOR_TYPE statement attribute was SQL_CURSOR_KEYSET_DRIVEN, but the value specified with the SQL_ATTR_KEYSET_SIZE statement attribute was greater than 0 and less than the value specified with the SQL_ATTR_ROW_ARRAY_SIZE statement 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 驱动程序或数据源不支持SQLBindColTargetType的组合指定的转换和相应列的 SQL 数据类型。The driver or data source does not support the conversion specified by the combination of the TargetType in SQLBindCol and the SQL data type of the corresponding column.
HYT00HYT00 超时时间已到Timeout expired 在数据源返回请求的结果集之前, 查询超时期限已过期。The query timeout period expired before the data source returned the requested result set. 超时期限通过 SQLSetStmtAttr、SQL_ATTR_QUERY_TIMEOUT 设置。The timeout period is set through SQLSetStmtAttr, SQL_ATTR_QUERY_TIMEOUT.
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.
IM017IM017 在异步通知模式下禁用轮询Polling is disabled in asynchronous notification mode 无论何时使用通知模型, 都将禁用轮询。Whenever the notification model is used, polling is disabled.
IM018IM018 尚未调用SQLCompleteAsync来完成此句柄上先前的异步操作。SQLCompleteAsync has not been called to complete the previous asynchronous operation on this handle. 如果句柄上的上一个函数调用返回 SQL_STILL_EXECUTING, 并且如果启用了通知模式, 则必须在句柄上调用SQLCompleteAsync , 才能执行后处理并完成操作。If the previous function call on the handle returns SQL_STILL_EXECUTING and if notification mode is enabled, SQLCompleteAsync must be called on the handle to do post-processing and complete the operation.

注释Comments

SQLFetch返回结果集中的下一个行集。SQLFetch returns the next rowset in the result set. 它只能在结果集存在时调用: 即, 在创建结果集的调用之后, 在该结果集上的游标结束之前。It can be called only while a result set exists: that is, after a call that creates a result set and before the cursor over that result set is closed. 如果绑定了任何列, 则它会返回这些列中的数据。If any columns are bound, it returns the data in those columns. 如果应用程序已指定一个指向行状态数组或缓冲区的指针 (在其中返回提取的行数), SQLFetch也将返回此信息。If the application has specified a pointer to a row status array or a buffer in which to return the number of rows fetched, SQLFetch also returns this information. SQLFetch的调用可以与对SQLFetchScroll的调用混合, 但不能与对SQLExtendedFetch的调用混合。Calls to SQLFetch can be mixed with calls to SQLFetchScroll but cannot be mixed with calls to SQLExtendedFetch. 有关详细信息, 请参阅提取数据行For more information, see Fetching a Row of Data.

如果 ODBC1.x 应用程序适用于 odbc2.x 驱动程序, 则驱动程序管理器会将SQLFetch调用映射到支持SQLExtendedFetch的 odbc 2.x驱动程序SQLExtendedFetchIf an ODBC 3 .x application works with an ODBC 2 .x driver, the Driver Manager maps SQLFetch calls to SQLExtendedFetch for an ODBC 2 .x driver that supports SQLExtendedFetch. 如果 ODBC2.x 驱动程序不支持SQLExtendedFetch, 则驱动程序管理器会将SQLFetch调用映射到 ODBC2.x 驱动程序中的SQLFetch , 该驱动程序只能提取一行。If the ODBC 2 .x driver does not support SQLExtendedFetch, the Driver Manager maps SQLFetch calls to SQLFetch in the ODBC 2 .x driver, which can fetch only a single row.

有关详细信息, 请参阅附录 G 中的块游标、可滚动游标和后向兼容性:向后兼容的驱动程序准则。For more information, see Block Cursors, Scrollable Cursors, and Backward Compatibility in Appendix G: Driver Guidelines for Backward Compatibility.

定位光标Positioning the Cursor

创建结果集时, 游标将定位在结果集的开始位置之前。When the result set is created, the cursor is positioned before the start of the result set. SQLFetch提取下一个行集。SQLFetch fetches the next rowset. 它等效于调用SQLFetchScroll , 并将FETCHORIENTATION设置为 SQL_FETCH_NEXT。It is equivalent to calling SQLFetchScroll with FetchOrientation set to SQL_FETCH_NEXT. 有关游标的详细信息, 请参阅游标块游标For more information about cursors, see Cursors and Block Cursors.

SQL_ATTR_ROW_ARRAY_SIZE 语句特性指定行集中的行数。The SQL_ATTR_ROW_ARRAY_SIZE statement attribute specifies the number of rows in the rowset. 如果SQLFetch提取的行集与结果集的末尾重叠, 则SQLFetch将返回部分行集。If the rowset being fetched by SQLFetch overlaps the end of the result set, SQLFetch returns a partial rowset. 也就是说, 如果 S + R-1 大于 L, 其中 S 是要提取的行集的起始行, 则 R 是行集的大小, L 是结果集中的最后一行, 则仅行集的第一 L + 1 行是有效的。That is, if S + R - 1 is greater than L, where S is the starting row of the rowset being fetched, R is the rowset size, and L is the last row in the result set, then only the first L - S + 1 rows of the rowset are valid. 其余行为空, 状态为 "SQL_ROW_NOROW"。The remaining rows are empty and have a status of SQL_ROW_NOROW.

SQLFetch返回后, 当前行是行集的第一行。After SQLFetch returns, the current row is the first row of the rowset.

下表中列出的规则根据此部分的第二个表中列出的条件, 描述了调用SQLFetch后的游标定位。The rules listed in the following table describe cursor positioning after a call to SQLFetch, based on the conditions listed in the second table in this section.

条件Condition 新行集的第一行First row of new rowset
开始之前Before start 11
CurrRowsetStartLastResultRow-RowsetSize [1] < = CurrRowsetStart <= LastResultRow - RowsetSize[1] CurrRowsetStart + RowsetSize[2]CurrRowsetStart + RowsetSize[2]
CurrRowsetStart > LastResultRow-RowsetSize[1]CurrRowsetStart > LastResultRow - RowsetSize[1] 结束后After end
结束后After end 结束后After end

[1] 如果行集大小在提取之间发生更改, 则这是与上一次提取一起使用的行集大小。[1] If the rowset size is changed between fetches, this is the rowset size that was used with the previous fetch.

[2] 如果行集大小在提取之间发生更改, 则这是用于新提取的行集大小。[2] If the rowset size is changed between fetches, this is the rowset size that was used with the new fetch.

表示法Notation 含义Meaning
开始之前Before start 块游标位于结果集的开头位置之前。The block cursor is positioned before the start of the result set. 如果新行集的第一行在结果集的开头之前, 则SQLFetch将返回 SQL_NO_DATA。If the first row of the new rowset is before the start of the result set, SQLFetch returns SQL_NO_DATA.
结束后After end 块游标位于结果集的结尾之后。The block cursor is positioned after the end of the result set. 如果新行集的第一行在结果集的末尾之后, 则SQLFetch将返回 SQL_NO_DATA。If the first row of the new rowset is after the end of the result set, SQLFetch returns SQL_NO_DATA.
CurrRowsetStartCurrRowsetStart 当前行集中第一行的编号。The number of the first row in the current rowset.
LastResultRowLastResultRow 结果集中的最后一行的行号。The number of the last row in the result set.
RowsetSizeRowsetSize 行集大小。The rowset size.

例如, 假设有一个结果集包含100行, 行集大小为5。For example, suppose a result set has 100 rows and the rowset size is 5. 下表显示了SQLFetch为不同起始位置返回的行集和返回代码。The following table shows the rowset and return code returned by SQLFetch for different starting positions.

当前行集Current rowset 返回代码Return code 新建行集New rowset 提取的行数# of rows fetched
开始之前Before start SQL_SUCCESSSQL_SUCCESS 1到51 to 5 55
1到51 to 5 SQL_SUCCESSSQL_SUCCESS 6到106 to 10 55
52至5652 to 56 SQL_SUCCESSSQL_SUCCESS 57至6157 to 61 55
91至9591 to 95 SQL_SUCCESSSQL_SUCCESS 96至10096 to 100 55
93至9793 to 97 SQL_SUCCESSSQL_SUCCESS 98到100。98 to 100. 行状态数组的第4行和第5行设置为 SQL_ROW_NOROW。Rows 4 and 5 of the row status array are set to SQL_ROW_NOROW. 33
96至10096 to 100 SQL_NO_DATASQL_NO_DATA 无。None. 00
99至10099 to 100 SQL_NO_DATASQL_NO_DATA 无。None. 00
结束后After end SQL_NO_DATASQL_NO_DATA 无。None. 00

返回绑定列中的数据Returning Data in Bound Columns

SQLFetch返回每行时, 它会将绑定到该列的缓冲区中的每个绑定列的数据放入其中。As SQLFetch returns each row, it puts the data for each bound column in the buffer bound to that column. 如果没有绑定列, SQLFetch将不返回任何数据, 而是向前移动块游标。If no columns are bound, SQLFetch returns no data but does move the block cursor forward. 仍可使用SQLGetData检索数据。The data can still be retrieved by using SQLGetData. 如果游标是多行游标 (即, SQL_ATTR_ROW_ARRAY_SIZE 大于 1), 则只有当使用SQLGetInfo 的 InfoType调用SQL_GETDATA_EXTENSIONS时, 才能调用SQLGetDataIf the cursor is a multirow cursor (that is, the SQL_ATTR_ROW_ARRAY_SIZE is greater than 1), SQLGetData can be called only if SQL_GD_BLOCK is returned when SQLGetInfo is called with an InfoType of SQL_GETDATA_EXTENSIONS. (有关详细信息, 请参阅SQLGetData。)(For more information, see SQLGetData.)

对于行中的每个绑定列, SQLFetch执行以下操作:For each bound column in a row, SQLFetch does the following:

  1. 将长度/指示器缓冲区设置为 SQL_NULL_DATA, 如果数据为 NULL, 则转到下一列。Sets the length/indicator buffer to SQL_NULL_DATA and proceeds to the next column if the data is NULL. 如果数据为空且未绑定长度/指示器缓冲区, 则SQLFetch将返回行的 SQLSTATE 22002 (需要指示器变量, 但未提供), 并转到下一行。If the data is NULL and no length/indicator buffer was bound, SQLFetch returns SQLSTATE 22002 (Indicator variable required but not supplied) for the row and proceeds to the next row. 有关如何确定长度/指示器缓冲区的地址的信息, 请参阅SQLBindCol中的 "缓冲区地址"。For information about how to determine the address of the length/indicator buffer, see "Buffer Addresses" in SQLBindCol.

    如果列的数据不为 NULL, 则SQLFetch将继续执行步骤2。If the data for the column is not NULL, SQLFetch proceeds to step 2.

  2. 如果 SQL_ATTR_MAX_LENGTH 语句特性设置为非零值, 并且列包含字符或二进制数据, 则数据将被截断为 SQL_ATTR_MAX_LENGTH 字节。If the SQL_ATTR_MAX_LENGTH statement attribute is set to a nonzero value and the column contains character or binary data, the data is truncated to SQL_ATTR_MAX_LENGTH bytes.

    备注

    SQL_ATTR_MAX_LENGTH 语句特性旨在减少网络流量。The SQL_ATTR_MAX_LENGTH statement attribute is intended to reduce network traffic. 它通常由数据源实现, 该数据源通过网络返回数据之前将其截断。It is generally implemented by the data source, which truncates the data before returning it over the network. 驱动程序和数据源不需要支持。Drivers and data sources are not required to support it. 因此, 若要保证数据被截断到特定大小, 应用程序应分配该大小的缓冲区, 并在SQLBindColcbValueMax参数中指定大小。Therefore, to guarantee that data is truncated to a particular size, an application should allocate a buffer of that size and specify the size in the cbValueMax argument in SQLBindCol.

  3. 将数据转换为SQLBindCol中由TargetType指定的类型。Converts the data to the type specified by TargetType in SQLBindCol.

  4. 如果将数据转换为可变长度的数据类型 (如字符或二进制), SQLFetch会检查数据长度是否超过数据缓冲区的长度。If the data was converted to a variable-length data type, such as character or binary, SQLFetch checks whether the length of the data exceeds the length of the data buffer. 如果字符数据的长度 (包括 null 终止字符) 超过了数据缓冲区的长度, 则SQLFetch会将数据截断到数据缓冲区长度减去 null 终止字符的长度。If the length of character data (including the null-termination character) exceeds the length of the data buffer, SQLFetch truncates the data to the length of the data buffer less the length of a null-termination character. 然后, 它将终止数据。It then null-terminates the data. 如果二进制数据的长度超过数据缓冲区的长度, 则SQLFetch会将其截断为数据缓冲区的长度。If the length of binary data exceeds the length of the data buffer, SQLFetch truncates it to the length of the data buffer. 数据缓冲区的长度是通过SQLBindCol中的BufferLength指定的。The length of the data buffer is specified with BufferLength in SQLBindCol.

    SQLFetch从不截断转换为固定长度数据类型的数据;它始终假定数据缓冲区的长度为数据类型的大小。SQLFetch never truncates data converted to fixed-length data types; it always assumes that the length of the data buffer is the size of the data type.

  5. 将转换后的数据 (可能截断后的数据) 放入数据缓冲区。Puts the converted (and possibly truncated) data in the data buffer. 有关如何确定数据缓冲区的地址的信息, 请参阅SQLBindCol中的 "缓冲区地址"。For information about how to determine the address of the data buffer, see "Buffer Addresses" in SQLBindCol.

  6. 将数据的长度放入长度/指示器缓冲区。Puts the length of the data in the length/indicator buffer. 如果指示器指针和长度指针均设置为同一个缓冲区 (作为对SQLBindCol的调用), 则在缓冲区中写入有效数据的长度, 并且在缓冲区中写入 NULL 数据。If the indicator pointer and the length pointer were both set to the same buffer (as a call to SQLBindCol does), the length is written in the buffer for valid data and SQL_NULL_DATA is written in the buffer for NULL data. 如果没有绑定长度/指示器缓冲区, 则SQLFetch不返回长度。If no length/indicator buffer was bound, SQLFetch does not return the length.

    • 对于字符或二进制数据, 这是转换后的数据长度, 在截断之前, 因为数据缓冲区太小。For character or binary data, this is the length of the data after conversion and before truncation because of the data buffer being too small. 如果驱动程序在转换后无法确定数据的长度, 有时会出现长数据的情况, 它会将长度设置为 SQL_NO_TOTAL。If the driver cannot determine the length of the data after conversion, as is sometimes the case with long data, it sets the length to SQL_NO_TOTAL. 如果由于 SQL_ATTR_MAX_LENGTH 语句特性而导致数据被截断, 则此属性的值将放入长度/指示器缓冲区而不是实际长度中。If data was truncated because of the SQL_ATTR_MAX_LENGTH statement attribute, the value of this attribute is put in the length/indicator buffer instead of the actual length . 这是因为该属性设计为在转换前截断服务器上的数据, 以便驱动程序无法确定实际长度。This is because this attribute is designed to truncate data on the server before conversion, so that the driver has no way of figuring out what the actual length is.

    • 对于所有其他数据类型, 这是转换后的数据长度;也就是说, 它是数据转换到的类型的大小。For all other data types, this is the length of the data after conversion; that is, it is the size of the type to which the data was converted.

    有关如何确定长度/指示器缓冲区的地址的信息, 请参阅SQLBindCol中的 "缓冲区地址"。For information about how to determine the address of the length/indicator buffer, see "Buffer Addresses" in SQLBindCol.

  7. 如果在转换过程中数据被截断 (例如, 在转换时将实数1.234 截断为整数 1), 则SQLFetch将返回 SQLSTATE 01S07 (小数截断) 和 SQL_SUCCESS_WITH_INFO。If the data is truncated during conversion without a loss of significant digits (for example, the real number 1.234 is truncated to the integer 1 when converted), SQLFetch returns SQLSTATE 01S07 (Fractional truncation) and SQL_SUCCESS_WITH_INFO. 如果由于数据缓冲区的长度太小 (例如, 字符串 "abcdef" 放在4字节缓冲区中) 而导致数据被截断, 则SQLFetch将返回 SQLSTATE 01004 (数据截断) 和 SQL_SUCCESS_WITH_INFO。If the data is truncated because the length of the data buffer is too small (for example, the string "abcdef" is put in a 4-byte buffer), SQLFetch returns SQLSTATE 01004 (Data truncated) and SQL_SUCCESS_WITH_INFO. 如果由于 SQL_ATTR_MAX_LENGTH 语句特性而导致数据被截断, 则SQLFetch将返回 SQL_SUCCESS, 而不会返回 SQLSTATE 01S07 (分段截断) 或 SQLSTATE 01004 (数据截断)。If data is truncated because of the SQL_ATTR_MAX_LENGTH statement attribute, SQLFetch returns SQL_SUCCESS and does not return SQLSTATE 01S07 (Fractional truncation) or SQLSTATE 01004 (Data truncated). 如果在转换过程中数据被截断 (例如, 如果将大于100000的 SQL_INTEGER 值转换为 SQL_C_TINYINT), 则SQLFetch将返回 SQLSTATE 22003 (数值超出范围) 和 SQL_ERROR (如果行集大小为 1) 或 SQL_SUCCESS_WITH_INFO (如果行集大小大于 1)。If data is truncated during conversion with a loss of significant digits (for example, if an SQL_INTEGER value greater than 100,000 were converted to an SQL_C_TINYINT), SQLFetch returns SQLSTATE 22003 (Numeric value out of range) and SQL_ERROR (if the rowset size is 1) or SQL_SUCCESS_WITH_INFO (if the rowset size is greater than 1).

如果SQLFetchSQLFETCHSCROLL未返回 SQL_SUCCESS 或 SQL_SUCCESS_WITH_INFO, 则绑定数据缓冲区和长度/指示器缓冲区的内容不确定。The contents of the bound data buffer and the length/indicator buffer are undefined if SQLFetch or SQLFetchScroll does not return SQL_SUCCESS or SQL_SUCCESS_WITH_INFO.

行状态数组Row Status Array

行状态数组用于返回行集中每行的状态。The row status array is used to return the status of each row in the rowset. 此数组的地址是用 SQL_ATTR_ROW_STATUS_PTR 语句特性指定的。The address of this array is specified with the SQL_ATTR_ROW_STATUS_PTR statement attribute. 数组由应用程序分配, 并且必须具有与 SQL_ATTR_ROW_ARRAY_SIZE 语句特性指定的数目相同的元素。The array is allocated by the application and must have as many elements as are specified by the SQL_ATTR_ROW_ARRAY_SIZE statement attribute. 它的值由SQLFetchSQLFetchScrollSQLBulkOperationsSQLSetPos设置 (在游标由SQLExtendedFetch定位后调用时除外)。Its values are set by SQLFetch, SQLFetchScroll, and SQLBulkOperations or SQLSetPos (except when they have been called after the cursor has been positioned by SQLExtendedFetch). 如果 SQL_ATTR_ROW_STATUS_PTR 语句特性的值为 null 指针, 则这些函数不返回行状态。If the value of the SQL_ATTR_ROW_STATUS_PTR statement attribute is a null pointer, these functions do not return the row status.

如果SQLFetchSQLFETCHSCROLL未返回 SQL_SUCCESS 或 SQL_SUCCESS_WITH_INFO, 则不定义行状态数组缓冲区的内容。The contents of the row status array buffer are undefined if SQLFetch or SQLFetchScroll does not return SQL_SUCCESS or SQL_SUCCESS_WITH_INFO.

行状态数组中将返回以下值。The following values are returned in the row status array.

行状态数组值Row status array value 描述Description
SQL_ROW_SUCCESSSQL_ROW_SUCCESS 该行已成功提取, 自从上次从此结果集中提取行后, 该行尚未发生更改。The row was successfully fetched and has not changed since it was last fetched from this result set.
SQL_ROW_SUCCESS_WITH_INFOSQL_ROW_SUCCESS_WITH_INFO 该行已成功提取, 自从上次从此结果集中提取行后, 该行尚未发生更改。The row was successfully fetched and has not changed since it was last fetched from this result set. 但对于该行, 返回了警告。However, a warning was returned about the row.
SQL_ROW_ERRORSQL_ROW_ERROR 提取行时出错。An error occurred while fetching the row.
SQL_ROW_UPDATED [1]、[2] 和 [3]SQL_ROW_UPDATED[1],[2], and [3] 该行已成功提取, 自从上次从此结果集中提取行后已发生更改。The row was successfully fetched and has changed since it was last fetched from this result set. 如果再次从此结果集中提取行或通过SQLSetPos刷新该行, 状态将更改为该行的新状态。If the row is fetched again from this result set or is refreshed by SQLSetPos, the status is changed to the row's new status.
SQL_ROW_DELETED[3]SQL_ROW_DELETED[3] 该行自上次从此结果集中提取后已被删除。The row has been deleted since it was last fetched from this result set.
SQL_ROW_ADDED[4]SQL_ROW_ADDED[4] 该行由SQLBulkOperations插入。The row was inserted by SQLBulkOperations. 如果再次从此结果集中提取行或通过SQLSetPos刷新该行, 则其状态为 SQL_ROW_SUCCESS。If the row is fetched again from this result set or is refreshed by SQLSetPos, its status is SQL_ROW_SUCCESS.
SQL_ROW_NOROWSQL_ROW_NOROW 行集与结果集的末尾重叠, 并且未返回对应行状态数组的此元素的行。The rowset overlapped the end of the result set, and no row was returned that corresponded to this element of the row status array.

[1] 对于键集、混合和动态游标, 如果更新键值, 则会将数据行视为已被删除并添加新行。[1] For keyset, mixed, and dynamic cursors, if a key value is updated, the row of data is considered to have been deleted and a new row added.

[2] 某些驱动程序无法检测到数据的更新, 因此无法返回此值。[2] Some drivers cannot detect updates to data and therefore cannot return this value. 若要确定驱动程序是否可以检测到制约行的更新, 应用程序将使用 SQL_ROW_UPDATES 选项调用SQLGetInfoTo determine whether a driver can detect updates to refetched rows, an application calls SQLGetInfo with the SQL_ROW_UPDATES option.

[3] SQLFetch只能在与对SQLFetchScroll的调用混合时返回此值。[3] SQLFetch can return this value only when it is intermixed with calls to SQLFetchScroll. 这是因为SQLFetch会在结果集中向前移动, 并在独占使用时, 不重新提取任何行。This is because SQLFetch moves forward through the result set and when it is used exclusively, does not refetch any rows. 由于没有制约的行, SQLFetch不检测对以前提取的行所做的更改。Because no rows are refetched, SQLFetch does not detect changes that were made to previously fetched rows. 但是, 如果SQLFetchScroll将游标定位在之前提取的行之前, 并使用SQLFetch提取这些行, 则SQLFetch可以检测对这些行所做的任何更改。However, if SQLFetchScroll positions the cursor before any previously fetched rows and SQLFetch is used to fetch those rows, SQLFetch can detect any changes to those rows.

[4] 仅由 SQLBulkOperations 返回。[4] Returned by SQLBulkOperations only. 不是由SQLFetchSQLFetchScroll设置的。Not set by SQLFetch or SQLFetchScroll.

提取的行缓冲区Rows Fetched Buffer

"提取的行" 缓冲区用于返回提取的行数, 包括因为在提取数据时出错而未返回数据的行数。The rows fetched buffer is used to return the number of rows fetched, including those rows for which no data was returned because an error occurred while they were being fetched. 换言之, 它是行状态数组中的值不是 SQL_ROW_NOROW 的行数。In other words, it is the number of rows for which the value in the row status array is not SQL_ROW_NOROW. 此缓冲区的地址是用 SQL_ATTR_ROWS_FETCHED_PTR 语句特性指定的。The address of this buffer is specified with the SQL_ATTR_ROWS_FETCHED_PTR statement attribute. 缓冲区由应用程序分配。The buffer is allocated by the application. 它由SQLFetchSQLFetchScroll设置。It is set by SQLFetch and SQLFetchScroll. 如果 SQL_ATTR_ROWS_FETCHED_PTR 语句特性的值为 null 指针, 则这些函数不返回提取的行数。If the value of the SQL_ATTR_ROWS_FETCHED_PTR statement attribute is a null pointer, these functions do not return the number of rows fetched. 若要确定结果集中的当前行数, 应用程序可以使用 SQL_ATTR_ROW_NUMBER 属性调用SQLGetStmtAttrTo determine the number of the current row in the result set, an application can call SQLGetStmtAttr with the SQL_ATTR_ROW_NUMBER attribute.

如果SQLFetchSQLFETCHSCROLL不返回 SQL_SUCCESS 或 SQL_SUCCESS_WITH_INFO (返回 SQL_NO_DATA 时除外), 则提取的行的内容将不确定, 在这种情况下, 提取缓冲区的行中的值将设置为0。The contents of the rows fetched buffer are undefined if SQLFetch or SQLFetchScroll does not return SQL_SUCCESS or SQL_SUCCESS_WITH_INFO, except when SQL_NO_DATA is returned, in which case the value in the rows fetched buffer is set to 0.

错误处理Error Handling

错误和警告可应用于单个行或整个函数。Errors and warnings can apply to individual rows or to the whole function. 有关诊断记录的详细信息, 请参阅诊断SQLGetDiagFieldFor more information about diagnostic records, see Diagnostics and SQLGetDiagField.

针对整个函数的错误和警告Errors and Warnings on the Entire Function

如果错误适用于整个函数 (如 SQLSTATE HYT00 (超时时间已过期) 或 SQLSTATE 24000 (无效的游标状态), 则SQLFetch返回 SQL_ERROR 和适用的 SQLSTATE。If an error applies to the entire function, such as SQLSTATE HYT00 (Timeout expired) or SQLSTATE 24000 (Invalid cursor state), SQLFetch returns SQL_ERROR and the applicable SQLSTATE. 行集缓冲区的内容未定义, 并且光标位置保持不变。The contents of the rowset buffers are undefined and the cursor position is unchanged.

如果警告适用于整个函数, 则SQLFetch将返回 SQL_SUCCESS_WITH_INFO 和适用的 SQLSTATE。If a warning applies to the entire function, SQLFetch returns SQL_SUCCESS_WITH_INFO and the applicable SQLSTATE. 适用于整个函数的警告的状态记录将在应用于单个行的状态记录之前返回。The status records for warnings that apply to the entire function are returned before the status records that apply to individual rows.

各个行中的错误和警告Errors and Warnings in Individual Rows

如果错误 (如 SQLSTATE 22012 (被零除)) 或警告 (例如 SQLSTATE 01004 (数据已截断)) 或警告 (例如, 已截断的数据), 则SQLFetch将执行以下操作:If an error (such as SQLSTATE 22012 (Division by zero)) or a warning (such as SQLSTATE 01004 (Data truncated)) applies to a single row, SQLFetchdoes the following:

  • 将行状态数组的相应元素设置为 SQL_ROW_ERROR 以查看错误, 或将 SQL_ROW_SUCCESS_WITH_INFO 设置为。Sets the corresponding element of the row status array to SQL_ROW_ERROR for errors or SQL_ROW_SUCCESS_WITH_INFO for warnings.

  • 添加零个或多个包含 SQLSTATEs 错误或警告的状态记录。Adds zero or more status records that contain SQLSTATEs for the error or warning.

  • 设置状态记录中的行号和列号字段。Sets the row and column number fields in the status records. 如果SQLFetch无法确定行号或列号, 则会将该数字分别设置为 SQL_ROW_NUMBER_UNKNOWN 或 SQL_COLUMN_NUMBER_UNKNOWN。If SQLFetch cannot determine a row or column number, it sets that number to SQL_ROW_NUMBER_UNKNOWN or SQL_COLUMN_NUMBER_UNKNOWN, respectively. 如果状态记录不适用于特定列, 则SQLFetch会将列号设置为 SQL_NO_COLUMN_NUMBER。If the status record does not apply to a particular column, SQLFetch sets the column number to SQL_NO_COLUMN_NUMBER.

SQLFetch在提取行集中的所有行之前继续提取行。SQLFetch continues fetching rows until it has fetched all the rows in the rowset. 它将返回 SQL_SUCCESS_WITH_INFO, 除非行集的每一行中发生错误 (不包括状态为 SQL_ROW_NOROW 的行), 在这种情况下, 它将返回 SQL_ERROR。It returns SQL_SUCCESS_WITH_INFO unless an error occurs in every row of the rowset (not including rows with status SQL_ROW_NOROW), in which case it returns SQL_ERROR. 具体而言, 如果行集的大小为 1, 并且该行发生错误, 则SQLFetch将返回 SQL_ERROR。In particular, if the rowset size is 1 and an error occurs in that row, SQLFetch returns SQL_ERROR.

SQLFetch按行号顺序返回状态记录。SQLFetch returns the status records in row number order. 也就是说, 它返回未知行 (如果有) 的所有状态记录;接下来, 它返回第一行 (如果有) 的所有状态记录, 然后返回第二行 (如果有) 的所有状态记录, 依此类推。That is, it returns all status records for unknown rows (if any); next it returns all status records for the first row (if any), and then it returns all status records for the second row (if any), and so on. 每行的状态记录根据排序状态记录的普通规则进行排序;有关详细信息, 请参阅SQLGetDiagField中的 "状态记录序列"。The status records for each row are ordered according to the normal rules for ordering status records; for more information, see "Sequence of Status Records" in SQLGetDiagField.

描述符和 SQLFetchDescriptors and SQLFetch

以下各节介绍了SQLFetch如何与描述符交互。The following sections describe how SQLFetch interacts with descriptors.

参数映射Argument Mappings

该驱动程序不根据SQLFetch的参数设置任何描述符字段。The driver does not set any descriptor fields based on the arguments of SQLFetch.

其他描述符字段Other Descriptor Fields

SQLFetch使用以下描述符字段。The following descriptor fields are used by SQLFetch.

描述符字段Descriptor field Desc.Desc. 字段Field in 设置为Set through
SQL_DESC_ARRAY_SIZESQL_DESC_ARRAY_SIZE ARDARD 标头header SQL_ATTR_ROW_ARRAY_SIZE 语句特性SQL_ATTR_ROW_ARRAY_SIZE statement attribute
SQL_DESC_ARRAY_STATUS_PTRSQL_DESC_ARRAY_STATUS_PTR IRDIRD 标头header SQL_ATTR_ROW_STATUS_PTR 语句特性SQL_ATTR_ROW_STATUS_PTR statement attribute
SQL_DESC_BIND_OFFSET_PTRSQL_DESC_BIND_OFFSET_PTR ARDARD 标头header SQL_ATTR_ROW_BIND_OFFSET_PTR 语句特性SQL_ATTR_ROW_BIND_OFFSET_PTR statement attribute
SQL_DESC_BIND_TYPESQL_DESC_BIND_TYPE ARDARD 标头header SQL_ATTR_ROW_BIND_TYPE 语句特性SQL_ATTR_ROW_BIND_TYPE statement attribute
SQL_DESC_COUNTSQL_DESC_COUNT ARDARD 标头header SQLBindColColumnNumber参数ColumnNumber argument of SQLBindCol
SQL_DESC_DATA_PTRSQL_DESC_DATA_PTR ARDARD 记录records SQLBindColTargetValuePtr参数TargetValuePtr argument of SQLBindCol
SQL_DESC_INDICATOR_PTRSQL_DESC_INDICATOR_PTR ARDARD 记录records SQLBindCol中的StrLen_or_IndPtr参数StrLen_or_IndPtr argument in SQLBindCol
SQL_DESC_OCTET_LENGTHSQL_DESC_OCTET_LENGTH ARDARD 记录records SQLBindCol中的BufferLength参数BufferLength argument in SQLBindCol
SQL_DESC_OCTET_LENGTH_PTRSQL_DESC_OCTET_LENGTH_PTR ARDARD 记录records SQLBindCol中的StrLen_or_IndPtr参数StrLen_or_IndPtr argument in SQLBindCol
SQL_DESC_ROWS_PROCESSED_PTRSQL_DESC_ROWS_PROCESSED_PTR IRDIRD 标头header SQL_ATTR_ROWS_FETCHED_PTR 语句特性SQL_ATTR_ROWS_FETCHED_PTR statement attribute
SQL_DESC_TYPESQL_DESC_TYPE ARDARD 记录records SQLBindCol中的TargetType参数TargetType argument in SQLBindCol

所有描述符字段也可以通过SQLSetDescField设置。All descriptor fields can also be set through SQLSetDescField.

分隔长度和指示器缓冲区Separate Length and Indicator Buffers

应用程序可以绑定单个缓冲区或两个单独的缓冲区, 这些缓冲区可用于保存长度和指示器值。Applications can bind a single buffer or two separate buffers that can be used to hold length and indicator values. 当应用程序调用SQLBindCol时, 驱动程序会将 ARD 的 SQL_DESC_OCTET_LENGTH_PTR 和 SQL_DESC_INDICATOR_PTR 字段设置为在StrLen_or_IndPtr参数中传递的同一地址。When an application calls SQLBindCol, the driver sets the SQL_DESC_OCTET_LENGTH_PTR and SQL_DESC_INDICATOR_PTR fields of the ARD to the same address, which is passed in the StrLen_or_IndPtr argument. 当应用程序调用SQLSetDescFieldSQLSetDescRec时, 它可以将这两个字段设置为不同地址。When an application calls SQLSetDescField or SQLSetDescRec, it can set these two fields to different addresses.

SQLFetch确定应用程序是否指定了单独的长度和指示器缓冲区。SQLFetch determines whether the application has specified separate length and indicator buffers. 在这种情况下, 当数据不为 NULL 时, SQLFetch会将指示器缓冲区设置为 0, 并返回长度缓冲区中的长度。In this case, when the data is not NULL, SQLFetch sets the indicator buffer to 0 and returns the length in the length buffer. 当数据为 NULL 时, SQLFetch会将指示器缓冲区设置为 SQL_NULL_DATA, 并且不会修改长度缓冲区。When the data is NULL, SQLFetch sets the indicator buffer to SQL_NULL_DATA and does not modify the length buffer.

代码示例Code Example

请参阅SQLBindColSQLColumnsSQLGetDataSQLProceduresSee SQLBindCol, SQLColumns, SQLGetData, and SQLProcedures.

有关信息For information about 请参阅See
将缓冲区绑定到结果集中的列Binding a buffer to a column in a result set SQLBindCol 函数SQLBindCol Function
正在取消语句处理Canceling statement processing SQLCancel 函数SQLCancel Function
返回有关结果集中的列的信息Returning information about a column in a result set SQLDescribeCol 函数SQLDescribeCol Function
执行 SQL 语句Executing an SQL statement SQLExecDirect 函数SQLExecDirect Function
执行已准备的 SQL 语句Executing a prepared SQL statement SQLExecute 函数SQLExecute Function
提取数据块或滚动结果集Fetching a block of data or scrolling through a result set SQLFetchScroll 函数SQLFetchScroll Function
在语句上关闭游标Closing the cursor on the statement SQLFreeStmt 函数SQLFreeStmt Function
提取部分或全部数据列Fetching part or all of a column of data SQLGetData 函数SQLGetData Function
返回结果集列的数目Returning the number of result set columns SQLNumResultCols 函数SQLNumResultCols Function
准备要执行的语句Preparing a statement for execution SQLPrepare 函数SQLPrepare Function

请参阅See Also

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