SQLSpecialColumns 函数SQLSpecialColumns Function

Conformance
引入的版本: ODBC 1.0 标准符合性:打开组Version Introduced: ODBC 1.0 Standards Compliance: Open Group

摘要Summary
SQLSpecialColumns 检索有关指定表中的列的下列信息:SQLSpecialColumns retrieves the following information about columns within a specified table:

  • 唯一标识表中的行的一组最佳列。The optimal set of columns that uniquely identifies a row in the table.

  • 当事务更新行中的任何值时,自动更新的列。Columns that are automatically updated when any value in the row is updated by a transaction.

语法Syntax

  
SQLRETURN SQLSpecialColumns(  
     SQLHSTMT      StatementHandle,  
     SQLSMALLINT   IdentifierType,  
     SQLCHAR *     CatalogName,  
     SQLSMALLINT   NameLength1,  
     SQLCHAR *     SchemaName,  
     SQLSMALLINT   NameLength2,  
     SQLCHAR *     TableName,  
     SQLSMALLINT   NameLength3,  
     SQLSMALLINT   Scope,  
     SQLSMALLINT   Nullable);  

参数Arguments

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

IdentifierTypeIdentifierType
送要返回的列的类型。[Input] Type of column to return. 必须是以下值之一:Must be one of the following values:

SQL_BEST_ROWID:通过从一列或多列检索值来返回最优列或一组列,允许唯一标识指定表中的任何行。SQL_BEST_ROWID: Returns the optimal column or set of columns that, by retrieving values from the column or columns, allows any row in the specified table to be uniquely identified. 列可以是专门为此目的而设计的伪列 (如 Oracle ROWID 或 Ingres TID) 或表的任何唯一索引的一个或多个列。A column can be either a pseudo-column specifically designed for this purpose (as in Oracle ROWID or Ingres TID) or the column or columns of any unique index for the table.

SQL_ROWVER:返回指定表中的一个或多个列(如果有),当任何事务更新行中的任何值时,该列或列将由数据源自动更新, (如 SQLBase ROWID 或 Sybase TIMESTAMP) 中所示。SQL_ROWVER: Returns the column or columns in the specified table, if any, that are automatically updated by the data source when any value in the row is updated by any transaction (as in SQLBase ROWID or Sybase TIMESTAMP).

CatalogNameCatalogName
送表的目录名称。[Input] Catalog name for the table. 如果驱动程序为某些表(而不是其他表)支持目录,例如当驱动程序从不同 Dbms 检索数据时(例如,当驱动程序检索不同 Dbms 的数据时),则空字符串 ( "" ) 表示这些表没有目录。If a driver supports catalogs for some tables but not for others, such as when the driver retrieves data from different DBMSs, an empty string ("") denotes those tables that do not have catalogs. CatalogName 不能包含字符串搜索模式。CatalogName cannot contain a string search pattern.

如果 SQL_ATTR_METADATA_ID 语句特性设置为 SQL_TRUE,则 CatalogName 被视为标识符,并且其大小写不重要。If the SQL_ATTR_METADATA_ID statement attribute is set to SQL_TRUE, CatalogName is treated as an identifier and its case is not significant. 如果 SQL_FALSE,则 CatalogName 是普通参数;它按原义处理,其大小写很重要。If it is SQL_FALSE, CatalogName is an ordinary argument; it is treated literally, and its case is significant. 有关详细信息,请参阅 目录函数中的参数For more information, see Arguments in Catalog Functions.

NameLength1NameLength1
送*CatalogName 中的字符的长度。[Input] Length in characters of *CatalogName.

SchemaNameSchemaName
送表的架构名称。[Input] Schema name for the table. 如果驱动程序支持某些表的架构,而不支持其他表的架构(例如,当驱动程序从不同 Dbms 检索数据时),则空字符串 ( "" ) 表示不具有架构的那些表。If a driver supports schemas for some tables but not for others, such as when the driver retrieves data from different DBMSs, an empty string ("") denotes those tables that do not have schemas. SchemaName 不能包含字符串搜索模式。SchemaName cannot contain a string search pattern.

如果 SQL_ATTR_METADATA_ID 语句特性设置为 SQL_TRUE,则 SchemaName 被视为标识符,并且其大小写不重要。If the SQL_ATTR_METADATA_ID statement attribute is set to SQL_TRUE, SchemaName is treated as an identifier and its case is not significant. 如果 SQL_FALSE,则 SchemaName 是普通参数;它按原义处理,其大小写很重要。If it is SQL_FALSE, SchemaName is an ordinary argument; it is treated literally, and its case is significant.

NameLength2NameLength2
送*SchemaName 中的字符的长度。[Input] Length in characters of *SchemaName.

TableNameTableName
送表名称。[Input] Table name. 此参数不能为 null 指针。This argument cannot be a null pointer. TableName 不能包含字符串搜索模式。TableName cannot contain a string search pattern.

如果 SQL_ATTR_METADATA_ID 语句特性设置为 SQL_TRUE,则 TableName 将被视为标识符,并且其大小写不重要。If the SQL_ATTR_METADATA_ID statement attribute is set to SQL_TRUE, TableName is treated as an identifier and its case is not significant. 如果 SQL_FALSE,则 TableName 为普通参数;它按原义处理,其大小写很重要。If it is SQL_FALSE, TableName is an ordinary argument; it is treated literally, and its case is significant.

NameLength3NameLength3
送*TableName 的长度(字符)。[Input] Length in characters of *TableName.

范围Scope
送Rowid 所需的最小范围。[Input] Minimum required scope of the rowid. 返回的 rowid 的作用域可能更大。The returned rowid may be of greater scope. 必须是下列选项之一:Must be one of the following:

SQL_SCOPE_CURROW:仅当定位在该行上时,rowid 才能保证有效。SQL_SCOPE_CURROW: The rowid is guaranteed to be valid only while positioned on that row. 如果行已由其他事务更新或删除,则以后使用 rowid 重新选择的可能不会返回一行。A later reselect using rowid may not return a row if the row was updated or deleted by another transaction.

SQL_SCOPE_TRANSACTION:保证 rowid 在当前事务的持续时间内有效。SQL_SCOPE_TRANSACTION: The rowid is guaranteed to be valid for the duration of the current transaction.

SQL_SCOPE_SESSION:保证 rowid 在会话的持续时间内保持有效 () 的事务边界。SQL_SCOPE_SESSION: The rowid is guaranteed to be valid for the duration of the session (across transaction boundaries).

可以为 NullNullable
送确定是否返回可以具有 NULL 值的特殊列。[Input] Determines whether to return special columns that can have a NULL value. 必须是下列选项之一:Must be one of the following:

SQL_NO_NULLS:排除可以具有 NULL 值的特殊列。SQL_NO_NULLS: Exclude special columns that can have NULL values. 某些驱动程序无法支持 SQL_NO_NULLS,如果指定 SQL_NO_NULLS,则这些驱动程序将返回空结果集。Some drivers cannot support SQL_NO_NULLS, and these drivers will return an empty result set if SQL_NO_NULLS was specified. 应用程序应为此情况做好准备,并且仅当绝对需要时才请求 SQL_NO_NULLS。Applications should be prepared for this case and request SQL_NO_NULLS only if it is absolutely required.

SQL_NULLABLE:返回特殊列,即使它们可以具有 NULL 值也是如此。SQL_NULLABLE: Return special columns even if they can have NULL values.

返回Returns

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

诊断Diagnostics

SQLSpecialColumns 返回 SQL_ERROR 或 SQL_SUCCESS_WITH_INFO 时,可以通过使用 HandleType 的 SQL_HANDLE_STMT 和 StatementHandle句柄 调用 SQLGetDiagRec 来获取关联的 SQLSTATE 值。When SQLSpecialColumns 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. 下表列出了通常由 SQLSpecialColumns 返回的 SQLSTATE 值,并对该函数的上下文中的每个值进行了说明:表示法 " (DM) " 位于驱动程序管理器返回的 SQLSTATEs 的说明之前。The following table lists the SQLSTATE values commonly returned by SQLSpecialColumns 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.)
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 StatementHandle 上打开了游标,并且调用了 SQLFetchSQLFetchScrollA cursor was open on the StatementHandle, and SQLFetch or SQLFetchScroll had been called. 如果未 SQL_NO_DATA 返回 SQLFetchSQLFetchScroll ,驱动程序管理器将返回此错误,如果 SQLFetchSQLFetchScroll 已返回 SQL_NO_DATA,则由驱动程序返回。This error is returned by the Driver Manager if SQLFetch or SQLFetchScroll has not returned SQL_NO_DATA and is returned by the driver if SQLFetch or SQLFetchScroll has returned SQL_NO_DATA.

StatementHandle 上打开了游标,但尚未调用 SQLFetchSQLFetchScrollA cursor was open on the StatementHandle, but SQLFetch or SQLFetchScroll had not been called.
4000140001 序列化失败Serialization failure 由于另一个事务发生了资源死锁,事务已回滚。The transaction was rolled back due to a resource deadlock with another transaction.
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 required to support execution or completion of the function.
HY008HY008 操作已取消Operation canceled 已为 StatementHandle 启用异步处理。Asynchronous processing was enabled for the StatementHandle. 函数被调用,在完成执行之前,在 StatementHandle 上调用了 SQLCancelSQLCancelHandleThe function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle. 然后,在 StatementHandle 上再次调用该函数。Then the function was called again on the StatementHandle.

函数被调用,在完成执行之前,从多线程应用程序中的另一个线程调用 StatementHandle 上的 SQLCancelSQLCancelHandleThe function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle from a different thread in a multithread application.
HY009HY009 空值指针的使用无效Invalid use of null pointer TableName 参数为 null 指针。The TableName argument was a null pointer.

SQL_ATTR_METADATA_ID 语句特性设置为 SQL_TRUE, CatalogName 参数为 null 指针,SQL_CATALOG_NAME 的 InfoType 返回支持的目录名称。The SQL_ATTR_METADATA_ID statement attribute was set to SQL_TRUE, the CatalogName argument was a null pointer, and the SQL_CATALOG_NAME InfoType returns that catalog names are supported.

(DM) SQL_ATTR_METADATA_ID 语句特性设置为 SQL_TRUE,并且 SchemaName 参数为 null 指针。(DM) The SQL_ATTR_METADATA_ID statement attribute was set to SQL_TRUE, and the SchemaName 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. 调用 SQLSpecialColumns 时仍在执行此函数。This function was still executing when SQLSpecialColumns 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) An asynchronously executing function (not this one) was called for the StatementHandle and was still executing when this function was called.

(DM) 为 StatementHandle 调用 SQLExecuteSQLExecDirectSQLBulkOperationsSQLSetPos ,并返回 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.
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 (DM) 一个长度参数的值小于0但不等于 SQL_NTS。(DM) The value of one of the length arguments was less than 0 but not equal to SQL_NTS.

其中一个长度参数的值超过了对应名称的最大长度值。The value of one of the length arguments exceeded the maximum length value for the corresponding name. 可以通过使用 InfoType 值调用 SQLGetInfo 来获取每个名称的最大长度: SQL_MAX_CATALOG_NAME_LEN、SQL_MAX_SCHEMA_NAME_LEN 或 SQL_MAX_TABLE_NAME_LEN。The maximum length of each name can be obtained by calling SQLGetInfo with the InfoType values: SQL_MAX_CATALOG_NAME_LEN, SQL_MAX_SCHEMA_NAME_LEN, or SQL_MAX_TABLE_NAME_LEN.
HY097HY097 列类型超出范围Column type out of range (DM) 指定了无效的 IdentifierType 值。(DM) An invalid IdentifierType value was specified.
HY098HY098 范围类型超出范围Scope type out of range (DM) 指定的 范围 值无效。(DM) An invalid Scope value was specified.
HY099HY099 可以为 null 的类型超出范围Nullable type out of range (DM) 指定了无效的 可以为 Null 的值。(DM) An invalid Nullable value was specified.
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 指定了一个目录,但该驱动程序或数据源不支持目录。A catalog was specified, and the driver or data source does not support catalogs.

指定了架构,但驱动程序或数据源不支持架构。A schema was specified, and the driver or data source does not support schemas.

驱动程序或数据源不支持 SQL_ATTR_CONCURRENCY 和 SQL_ATTR_CURSOR_TYPE 语句特性的当前设置的组合。The combination of the current settings of the SQL_ATTR_CONCURRENCY and SQL_ATTR_CURSOR_TYPE statement attributes was not supported by the driver or data source.

SQL_ATTR_USE_BOOKMARKS 语句特性设置为 SQL_UB_VARIABLE,并且 SQL_ATTR_CURSOR_TYPE 语句特性设置为该驱动程序不支持书签的游标类型。The SQL_ATTR_USE_BOOKMARKS statement attribute was set to SQL_UB_VARIABLE, and the SQL_ATTR_CURSOR_TYPE statement attribute was set to a cursor type for which the driver does not support bookmarks.
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

如果 SQL_BEST_ROWID IdentifierType 参数,则 SQLSpecialColumns 将返回唯一标识表中每行的一列或多列。When the IdentifierType argument is SQL_BEST_ROWID, SQLSpecialColumns returns the column or columns that uniquely identify each row in the table. 这些列始终可在 选择列表WHERE 子句中使用。These columns can always be used in a select-list or WHERE clause. SQLColumns 用于返回表中各列的信息,不一定返回唯一标识每行的列,或在某一事务更新行中的任何值时自动更新的列。SQLColumns, which is used to return a variety of information on the columns of a table, does not necessarily return the columns that uniquely identify each row, or columns that are automatically updated when any value in the row is updated by a transaction. 例如, SQLColumns 可能不会返回 Oracle 伪列 ROWID。For example, SQLColumns might not return the Oracle pseudo-column ROWID. 这就是使用 SQLSpecialColumns 来返回这些列的原因。This is why SQLSpecialColumns is used to return these columns. 有关详细信息,请参阅 目录数据的使用For more information, see Uses of Catalog Data.

备注

有关 ODBC 目录函数的常规用法、参数和返回数据的详细信息,请参阅 目录函数For more information about the general use, arguments, and returned data of ODBC catalog functions, see Catalog Functions.

如果没有列唯一标识表中的每一行,则 SQLSpecialColumns 将返回没有行的行集;对该语句的 SQLFetchSQLFetchScroll 的后续调用将返回 SQL_NO_DATA。If there are no columns that uniquely identify each row in the table, SQLSpecialColumns returns a rowset with no rows; a subsequent call to SQLFetch or SQLFetchScroll on the statement returns SQL_NO_DATA.

如果 IdentifierType范围可以为 null 的参数指定数据源不支持的特性,则 SQLSpecialColumns 将返回一个空结果集。If the IdentifierType, Scope, or Nullable arguments specify characteristics that are not supported by the data source, SQLSpecialColumns returns an empty result set.

如果 SQL_ATTR_METADATA_ID 语句特性设置为 SQL_TRUE,则 CatalogNameSchemaNameTableName 参数被视为标识符,因此在某些情况下它们不能设置为 null 指针。If the SQL_ATTR_METADATA_ID statement attribute is set to SQL_TRUE, the CatalogName, SchemaName, and TableName arguments are treated as identifiers, so they cannot be set to a null pointer in certain situations. (有关详细信息,请参阅 目录函数中的参数。 ) (For more information, see Arguments in Catalog Functions.)

SQLSpecialColumns 以标准结果集的形式返回结果,并按作用域排序。SQLSpecialColumns returns the results as a standard result set, ordered by SCOPE.

为 ODBC 2.x 重命名了以下列。The following columns have been renamed for ODBC 3.x. 列名称更改不会影响向后兼容性,因为应用程序按列号进行绑定。The column name changes do not affect backward compatibility because applications bind by column number.

ODBC 2.0 列ODBC 2.0 column ODBC 2.xODBC 3.x column
PRECISIONPRECISION COLUMN_SIZECOLUMN_SIZE
LENGTHLENGTH BUFFER_LENGTHBUFFER_LENGTH
SCALESCALE DECIMAL_DIGITSDECIMAL_DIGITS

若要确定 COLUMN_NAME 列的实际长度,应用程序可以使用 SQL_MAX_COLUMN_NAME_LEN 选项调用 SQLGetInfoTo determine the actual length of the COLUMN_NAME column, an application can call SQLGetInfo with the SQL_MAX_COLUMN_NAME_LEN option.

下表列出了结果集中的列。The following table lists the columns in the result set. 列8以外的其他列 (PSEUDO_COLUMN) 可由驱动程序定义。Additional columns beyond column 8 (PSEUDO_COLUMN) can be defined by the driver. 应用程序应通过从结果集的末尾倒计时而不是指定显式序号位置,来获取对驱动程序特定列的访问权限。An application should gain access to driver-specific columns by counting down from the end of the result set rather than specifying an explicit ordinal position. 有关详细信息,请参阅 目录函数返回的数据For more information, see Data Returned by Catalog Functions.

列名称Column name 列号Column number 数据类型Data type 注释Comments
范围 (ODBC 1.0) SCOPE (ODBC 1.0) 11 SmallintSmallint Rowid 的实际作用域。Actual scope of the rowid. 包含以下值之一:Contains one of the following values:

SQL_SCOPE_CURROW SQL_SCOPE_TRANSACTION SQL_SCOPE_SESSIONSQL_SCOPE_CURROW SQL_SCOPE_TRANSACTION SQL_SCOPE_SESSION

SQL_ROWVER IdentifierType 时,将返回 NULL。NULL is returned when IdentifierType is SQL_ROWVER. 有关每个值的说明,请参阅本节前面部分中的 "语法" 的 范围 说明。For a description of each value, see the description of Scope in "Syntax," earlier in this section.
COLUMN_NAME (ODBC 1.0) COLUMN_NAME (ODBC 1.0) 22 Varchar not NULLVarchar not NULL 列名称。Column name. 对于没有名称的列,驱动程序返回空字符串。The driver returns an empty string for a column that does not have a name.
DATA_TYPE (ODBC 1.0) DATA_TYPE (ODBC 1.0) 33 Smallint(非 NULL)Smallint not NULL SQL 数据类型。SQL data type. 这可以是 ODBC SQL 数据类型,也可以是特定于驱动程序的 SQL 数据类型。This can be an ODBC SQL data type or a driver-specific SQL data type. 有关有效 ODBC SQL 数据类型的列表,请参阅 SQL 数据类型For a list of valid ODBC SQL data types, see SQL Data Types. 有关特定于驱动程序的 SQL 数据类型的信息,请参阅驱动程序的文档。For information about driver-specific SQL data types, see the driver's documentation.
TYPE_NAME (ODBC 1.0) TYPE_NAME (ODBC 1.0) 44 Varchar not NULLVarchar not NULL 依赖于数据源的数据类型名称;例如,"CHAR"、"VARCHAR"、"MONEY"、"LONG VARBINARY" 或 "CHAR ( ) 用于位数据"。Data source-dependent data type name; for example, "CHAR", "VARCHAR", "MONEY", "LONG VARBINARY", or "CHAR ( ) FOR BIT DATA".
COLUMN_SIZE (ODBC 1.0) COLUMN_SIZE (ODBC 1.0) 55 IntegerInteger 数据源中列的大小。The size of the column on the data source. 有关列大小的详细信息,请参阅 列大小、十进制数字、传输八位字节长度和显示大小For more information concerning column size, see Column Size, Decimal Digits, Transfer Octet Length, and Display Size.
BUFFER_LENGTH (ODBC 1.0) BUFFER_LENGTH (ODBC 1.0) 66 IntegerInteger 当指定 SQL_C_DEFAULT 时,在 SQLGetDataSQLFetch 操作上传输的数据的长度(以字节为单位)。The length in bytes of data transferred on an SQLGetData or SQLFetch operation if SQL_C_DEFAULT is specified. 对于数值数据,此大小可能不同于数据源中存储的数据的大小。For numeric data, this size may be different than the size of the data stored on the data source. 此值与字符或二进制数据的 COLUMN_SIZE 列相同。This value is the same as the COLUMN_SIZE column for character or binary data. 有关详细信息,请参阅 列大小、十进制数字、传输八位字节长度和显示大小For more information, see Column Size, Decimal Digits, Transfer Octet Length, and Display Size.
DECIMAL_DIGITS (ODBC 1.0) DECIMAL_DIGITS (ODBC 1.0) 77 SmallintSmallint 数据源中列的小数位数。The decimal digits of the column on the data source. 对于不适用十进制数字的数据类型,将返回 NULL。NULL is returned for data types where decimal digits are not applicable. 有关十进制数字的详细信息,请参阅 列大小、十进制数字、传输八位字节长度和显示大小For more information concerning decimal digits, see Column Size, Decimal Digits, Transfer Octet Length, and Display Size.
PSEUDO_COLUMN (ODBC 2.0) PSEUDO_COLUMN (ODBC 2.0) 88 SmallintSmallint 指示列是否为伪列,如 Oracle ROWID:Indicates whether the column is a pseudo-column, such as Oracle ROWID:

SQL_PC_UNKNOWN SQL_PC_NOT_PSEUDO SQL_PC_PSEUDO 注意: 为了获得最大互操作性,不应使用 SQLGetInfo 返回的标识符引号字符将伪列括起来。SQL_PC_UNKNOWN SQL_PC_NOT_PSEUDO SQL_PC_PSEUDO Note: For maximum interoperability, pseudo-columns should not be quoted with the identifier quote character returned by SQLGetInfo.

在应用程序检索 SQL_BEST_ROWID 的值之后,应用程序可以使用这些值在定义的范围内重新选择该行。After the application retrieves values for SQL_BEST_ROWID, the application can use these values to reselect that row within the defined scope. SELECT 语句保证返回无行或一行。The SELECT statement is guaranteed to return either no rows or one row.

如果应用程序 reselects 基于 rowid 列或列的行,但找不到该行,则应用程序可以假定该行已被删除或 rowid 列已被修改。If an application reselects a row based on the rowid column or columns and the row is not found, the application can assume that the row was deleted or the rowid columns were modified. 相反的情况并不是这样:即使 rowid 未更改,该行中的其他列也可能已更改。The opposite is not true: even if the rowid has not changed, the other columns in the row may have changed.

对于需要在结果集内向前和向后滚动以检索一组行中的最新数据的应用程序,列类型 SQL_BEST_ROWID 返回的列很有用。Columns returned for column type SQL_BEST_ROWID are useful for applications that need to scroll forward and back within a result set to retrieve the most recent data from a set of rows. 在定位在该行上时,可保证 rowid 的一列或多列不发生变化。The column or columns of the rowid are guaranteed not to change while positioned on that row.

即使游标未定位在行上,rowid 的一列或多列仍可能仍然有效;应用程序可以通过检查结果集中的 "范围" 列来确定这一点。The column or columns of the rowid may remain valid even when the cursor is not positioned on the row; the application can determine this by checking the SCOPE column in the result set.

对于列类型 SQL_ROWVER 返回的列对于需要能够检查是否已更新给定行中的任何列是否已在使用 rowid 只有行时进行了更新的应用程序很有用。Columns returned for column type SQL_ROWVER are useful for applications that need the ability to check whether any columns in a given row have been updated while the row was reselected using the rowid. 例如,在使用 rowid 重新选择行后,应用程序可以将 SQL_ROWVER 列中以前的值与刚刚提取的值进行比较。For example, after reselecting a row using rowid, the application can compare the previous values in the SQL_ROWVER columns to the ones just fetched. 如果 SQL_ROWVER 列中的值与以前的值不同,则应用程序可以警告用户显示的数据已更改。If the value in a SQL_ROWVER column differs from the previous value, the application can alert the user that data on the display has changed.

代码示例Code Example

有关类似函数的代码示例,请参阅 SQLColumnsFor a code example of a similar function, see SQLColumns.

有关以下方面的信息For information about 请参阅See
将缓冲区绑定到结果集中的列Binding a buffer to a column in a result set SQLBindCol 函数SQLBindCol Function
正在取消语句处理Canceling statement processing SQLCancel 函数SQLCancel Function
返回一个或多个表中的列Returning the columns in a table or tables SQLColumns 函数SQLColumns Function
按只进方向提取单个行或数据块Fetching a single row or a block of data in a forward-only direction SQLFetch 函数SQLFetch Function
提取数据块或滚动结果集Fetching a block of data or scrolling through a result set SQLFetchScroll Function(SQLFetchScroll 函数)SQLFetchScroll Function
返回主键的列Returning the columns of a primary key SQLPrimaryKeys 函数SQLPrimaryKeys Function

另请参阅See Also

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