SQLExecDirect 函数SQLExecDirect Function

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

摘要Summary
SQLExecDirect执行可准备对象的语句,使用参数标记变量的当前值,如果在语句中存在任何参数。SQLExecDirect executes a preparable statement, using the current values of the parameter marker variables if any parameters exist in the statement. SQLExecDirect是提交一次性执行的 SQL 语句的最快方法。SQLExecDirect is the fastest way to submit an SQL statement for one-time execution.

语法Syntax

  
SQLRETURN SQLExecDirect(  
     SQLHSTMT     StatementHandle,  
     SQLCHAR *    StatementText,  
     SQLINTEGER   TextLength);  

参数Arguments

StatementHandleStatementHandle
[输入]语句句柄。[Input] Statement handle.

StatementTextStatementText
[输入]若要执行的 SQL 语句。[Input] SQL statement to be executed.

TextLengthTextLength
[输入]长度 *StatementText以字符为单位。[Input] Length of *StatementText in characters.

返回Returns

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

诊断Diagnostics

SQLExecDirect返回 SQL_ERROR 或 SQL_SUCCESS_WITH_INFO,可以通过调用获取关联的 SQLSTATE 值SQLGetDiagRecHandleType设置为 SQL_HANDLE_STMT,和一个处理StatementHandleWhen SQLExecDirect returns either SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. 下表列出了通常返回的 SQLSTATE 值SQLExecDirect ,并解释了此函数; 每个上下文中的表示法"(数据挖掘)"之前 SQLSTATEs 返回由驱动程序管理器的说明。The following table lists the SQLSTATE values commonly returned by SQLExecDirect 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 ErrorError 描述Description
0100001000 常规警告General warning 特定于驱动程序的信息性消息。Driver-specific informational message. (函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
0100101001 游标操作冲突Cursor operation conflict *StatementText包含定位的 update 或 delete 语句,并且没有行或多个行未更新或删除。*StatementText contained a positioned update or delete statement, and no rows or more than one row were updated or deleted. (有关对多个行的更新的详细信息,请参阅说明 SQL_ATTR_SIMULATE_CURSOR特性SQLSetStmtAttr。)(For more information about updates to more than one row, see the description of the SQL_ATTR_SIMULATE_CURSOR Attribute in SQLSetStmtAttr.)

(函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
0100301003 Set 函数中消除了空值NULL value eliminated in set function 自变量StatementText包含一个集函数 (如AVG最大MIN,依次类推),但不是计数设置函数,并且 NULL 参数值在应用函数之前已被消除。The argument StatementText contained a set function (such as AVG, MAX, MIN, and so on), but not the COUNT set function, and NULL argument values were eliminated before the function was applied. (函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
0100401004 字符串数据,右截断String data, right truncated 字符串或二进制数据返回为输入/输出或输出参数导致的非空白字符或非 NULL 二进制数据截断。String or binary data returned for an input/output or output parameter resulted in the truncation of nonblank character or non-NULL binary data. 如果它是一个字符串值,它是右侧被截断。If it was a string value, it was right-truncated. (函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
0100601006 未撤消特权Privilege not revoked *StatementText包含撤消语句,并且用户不具有指定的特权。*StatementText contained a REVOKE statement, and the user did not have the specified privilege. (函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
0100701007 未授予特权Privilege not granted *StatementText授予语句,并且用户可能不授予指定的特权。*StatementText was a GRANT statement, and the user could not be granted the specified privilege.
01S0201S02 选项值已更改Option value changed 指定的语句属性实现运行情况,由于无效,因此已暂时替换一个相近的值。A specified statement attribute was invalid because of implementation working conditions, so a similar value was temporarily substituted. (SQLGetStmtAttr可以调用以确定暂时被替换的值是什么。)替换值是否为有效StatementHandle直到关闭游标,此时语句属性将恢复为以前的值。(SQLGetStmtAttr can be called to determine what the temporarily substituted value is.) 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_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_SIMULATE_CURSOR

(函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
01S0701S07 截断小数部分Fractional truncation 用于输入/输出返回的数据或输出参数已被截断数值数据类型的小数部分被截断或时间部分的时间、 时间戳或时间间隔的数据类型的小数部分被截断。The data returned for an input/output or output parameter was truncated such that the fractional part of a numeric data type was truncated or the fractional portion of the time component of a time, timestamp, or interval data type was truncated.

(函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
0700207002 COUNT 字段不正确COUNT field incorrect 在指定的参数数目SQLBindParameter中包含的 SQL 语句中的参数数量小于* StatementTextThe number of parameters specified in SQLBindParameter was less than the number of parameters in the SQL statement contained in *StatementText.

SQLBindParameter调用时使用ParameterValuePtr设置为 null 指针StrLen_or_IndPtr未设置为 SQL_NULL_DATA 或 SQL_DATA_AT_EXEC,和InputOutputType不将设置为 SQL_PARAM_OUTPUT,以便在指定的参数数目SQLBindParameter大于中包含的 SQL 语句中的参数数目 *StatementText.SQLBindParameter was called with ParameterValuePtr set to a null pointer, StrLen_or_IndPtr not set to SQL_NULL_DATA or SQL_DATA_AT_EXEC, and InputOutputType not set to SQL_PARAM_OUTPUT, so that the number of parameters specified in SQLBindParameter was greater than the number of parameters in the SQL statement contained in *StatementText.
0700607006 受限制的数据类型属性冲突Restricted data type attribute violation 标识的数据值ValueType中的参数SQLBindParameter无法为数据类型由标识转换绑定的参数为ParameterType中的参数SQLBindParameterThe data value identified by the ValueType argument in SQLBindParameter for the bound parameter could not be converted to the data type identified by the ParameterType argument in SQLBindParameter.

参数绑定为 SQL_PARAM_INPUT_OUTPUT 或 SQL_PARAM_OUTPUT 不无法转换为标识的数据类型返回的数据值ValueType中的参数SQLBindParameterThe data value returned for a parameter bound as SQL_PARAM_INPUT_OUTPUT or SQL_PARAM_OUTPUT could not be converted to the data type identified by the ValueType argument in SQLBindParameter.

(如果无法转换为一个或多个行的数据值,但没有成功返回一个或多个行,此函数返回 SQL_SUCCESS_WITH_INFO。)(If the data values for one or more rows could not be converted but one or more rows were successfully returned, this function returns SQL_SUCCESS_WITH_INFO.)
0700707007 受限制的参数值冲突Restricted parameter value violation 参数类型 SQL_PARAM_INPUT_OUTPUT_STREAM 仅用于发送和接收数据部分中的参数。The parameter type SQL_PARAM_INPUT_OUTPUT_STREAM is only used for a parameter that sends and receives data in parts. 输入此参数类型不允许绑定的缓冲区。An input bound buffer is not allowed for this parameter type.

参数类型是 SQL_PARAM_INPUT_OUTPUT,以及时,将发生此错误* StrLen_or_IndPtr中指定SQLBindParameter不等于 SQL_NULL_DATA,SQL_DEFAULT_PARAM、 SQL_LEN_DATA_AT_EXEC(len) 或 SQL_DATA_AT_EXEC。This error will occur when the parameter type is SQL_PARAM_INPUT_OUTPUT, and when the *StrLen_or_IndPtr specified in SQLBindParameter is not equal to SQL_NULL_DATA, SQL_DEFAULT_PARAM, SQL_LEN_DATA_AT_EXEC(len), or SQL_DATA_AT_EXEC.
07S0107S01 默认参数的使用无效Invalid use of default parameter 参数值,设置SQLBindParameter、 是 SQL_DEFAULT_PARAM,并且相应参数没有默认值。A parameter value, set with SQLBindParameter, was SQL_DEFAULT_PARAM, and the corresponding parameter did not have a default value.
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.
21S0121S01 插入值列表与列列表不匹配Insert value list does not match column list *StatementText包含插入语句和要插入的值的数目不匹配的派生表的程度。*StatementText contained an INSERT statement, and the number of values to be inserted did not match the degree of the derived table.
21S0221S02 派生表等级与列列表不匹配Degree of derived table does not match column list *StatementText包含CREATE VIEW语句和非限定的列列表 (图中指定的列数列标识符参数的 sql语句) 包含定义的派生表中的列数与多个名称,查询规范SQL 语句的参数。*StatementText contained a CREATE VIEW statement, and the unqualified column list (the number of columns specified for the view in the column-identifier arguments of the SQL statement) contained more names than the number of columns in the derived table defined by the query-specification argument of the SQL statement.
2200122001 字符串数据,右截断String data, right truncation 字符或二进制值的列的分配时截断了非空白字符数据或非 null 的二进制数据。The assignment of a character or binary value to a column resulted in the truncation of nonblank character data or non-null binary data.
2200222002 需要指示器变量,但未提供Indicator variable required but not supplied NULL 数据被绑定到一个输出参数,其StrLen_or_IndPtr设置SQLBindParameter是空指针。NULL data was bound to an output parameter whose StrLen_or_IndPtr set by SQLBindParameter was a null pointer.
2200322003 数值超出范围Numeric value out of range *StatementText包含包含绑定的数值参数、 文字、 一个 SQL 语句,并且值被截断时分配给关联的表列数字的整个 (而不是小数) 部分。*StatementText contained an SQL statement that contained a bound numeric parameter or literal, and the value caused the whole (as opposed to fractional) part of the number to be truncated when assigned to the associated table column.

返回一个数字值 (数值或字符串) 的一个或多个输入/输出参数或输出参数将导致要截断的数字的整个 (而不是小数) 部分。Returning a numeric value (as numeric or string) for one or more input/output or output parameters would have caused the whole (as opposed to fractional) part of the number to be truncated.
2200722007 日期时间格式无效Invalid datetime format *StatementText包含了包含日期、 时间戳结构作为绑定参数,一个 SQL 语句,该参数,分别,无效的日期、 时间戳。*StatementText contained an SQL statement that contained a date, time, or timestamp structure as a bound parameter, and the parameter was, respectively, an invalid date, time, or timestamp.

输入/输出或输出参数绑定到日期、 时间或时间戳 C 结构,返回的参数中的值时,分别,无效的日期、 时间戳。An input/output or output parameter was bound to a date, time, or timestamp C structure, and a value in the returned parameter was, respectively, an invalid date, time, or timestamp. (函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
2200822008 日期时间字段溢出Datetime field overflow *StatementText包含包含日期时间表达式,计算,产生的日期时间戳结构的 SQL 语句无效。*StatementText contained an SQL statement that contained a datetime expression that, when computed, resulted in a date, time, or timestamp structure that was invalid.

日期时间表达式计算的输入/输出或输出参数导致了日期、 时间或时间戳 C 结构无效。A datetime expression computed for an input/output or output parameter resulted in a date, time, or timestamp C structure that was invalid.
2201222012 被零除Division by zero *StatementText包含了一个包含导致被零除的算术表达式的 SQL 语句。*StatementText contained an SQL statement that contained an arithmetic expression that caused division by zero.

算术表达式计算的输入/输出或输出参数导致除零。An arithmetic expression calculated for an input/output or output parameter resulted in division by zero.
2201522015 间隔字段溢出Interval field overflow *StatementText包含一个确切的数值或时间间隔参数,当转换到 SQL 数据类型的时间间隔,导致重要数字丢失。*StatementText contained an exact numeric or interval parameter that, when converted to an interval SQL data type, caused a loss of significant digits.

*StatementText包含多个字段是间隔参数,当转换为数值数据类型列中,没有表示形式具有数值数据类型。*StatementText contained an interval parameter with more than one field that, when converted to a numeric data type in a column, had no representation in the numeric data type.

*StatementText包含已分配到的时间间隔 SQL 类型的参数数据,并且在时间间隔内 SQL 类型的 C 类型的值没有表示形式。*StatementText contained parameter data that was assigned to an interval SQL type, and there was no representation of the value of the C type in the interval SQL type.

分配为精确数字或间隔时导致重要数字丢失 C 间隔类型到 SQL 类型的输入/输出或输出参数。Assigning an input/output or output parameter that was an exact numeric or interval SQL type to an interval C type caused a loss of significant digits.

输入/输出或输出参数分配给一个 C 间隔结构,间隔数据结构中的数据没有表示形式。When an input/output or output parameter was assigned to an interval C structure, there was no representation of the data in the interval data structure.
2201822018 转换指定的字符值无效Invalid character value for cast specification *StatementText包含 C 类型的为准确或近似数值、 日期时间或间隔数据类型; 该列的 SQL 类型是字符数据类型; 和列中的值不是有效的绑定 C 类型的文本。*StatementText contained a C type that 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.

SQL 类型时返回的输入/输出或输出参数,已准确或近似数值、 日期时间或间隔数据类型;C 类型为 SQL_C_CHAR;和列中的值不是有效的绑定的 SQL 类型的文本。When an input/output or output parameter was returned, the SQL type was an exact or approximate numeric, a datetime, or an interval data type; the C type was SQL_C_CHAR; and the value in the column was not a valid literal of the bound SQL type.
2201922019 无效的转义字符Invalid escape character *StatementText包含了包含一个 SQL 语句谓词以及转义其中子句和转义符的长度之后的字符转义不是等于 1。*StatementText contained an SQL statement that contained a LIKE predicate with an ESCAPE in the WHERE clause, and the length of the escape character following ESCAPE was not equal to 1.
2202522025 无效的转义序列Invalid escape sequence *StatementText包含了包含一个 SQL 语句"模式值转义转义符"中其中子句和后面的模式值中的转义字符的字符不是之一"%"或""。*StatementText contained an SQL statement that contained "LIKE pattern value ESCAPE escape character" in the WHERE clause, and the character following the escape character in the pattern value was not one of "%" or "".
2300023000 完整性约束冲突Integrity constraint violation *StatementText包含了一个包含参数的 SQL 语句。*StatementText contained an SQL statement that contained a parameter or literal. 参数值为空的定义为 NOT NULL 列关联的表中的列、 列约束为仅包含唯一值,却提供了重复的值或违反了某个其他的完整性约束。The parameter value was NULL for a column defined as NOT NULL in the associated table column, a duplicate value was supplied for a column constrained to contain only unique values, or some other integrity constraint was violated.
2400024000 游标状态无效Invalid cursor state 在光标StatementHandle通过SQLFetchSQLFetchScrollA cursor was positioned on the StatementHandle by SQLFetch or SQLFetchScroll. 如果此错误返回由驱动程序管理器SQLFetchSQLFetchScroll未返回 SQL_NO_DATA,和如果驱动程序返回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.

游标已打开但未在定位StatementHandleA cursor was open but not positioned on the StatementHandle.

*StatementText包含和定位的 update 或 delete 语句,游标早于开始日期的结果集或结果集的末尾之后位置。*StatementText contained a positioned update or delete statement, and the cursor was positioned before the start of the result set or after the end of the result set.
3400034000 无效的游标名称Invalid cursor name *StatementText包含和定位的 update 或 delete 语句,正在执行的语句所引用的游标未打开。*StatementText contained a positioned update or delete statement, and the cursor referenced by the statement being executed was not open.
3D0003D000 目录名称无效Invalid catalog name 中指定的目录名称StatementText无效。The catalog name specified in StatementText was invalid.
3F0003F000 无效的架构名称Invalid schema name 中指定的架构名称StatementText无效。The schema name specified in StatementText was invalid.
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.
4200042000 语法错误或访问冲突Syntax error or access violation *StatementText包含 SQL 语句不是可准备对象或包含语法错误。*StatementText contained an SQL statement that was not preparable or contained a syntax error.

用户没有权限执行 SQL 语句中包含 *StatementTextThe user did not have permission to execute the SQL statement contained in *StatementText.
42S0142S01 基表或视图已存在Base table or view already exists *StatementText包含CREATE TABLECREATE VIEW语句和表名称或视图指定名称已存在。*StatementText contained a CREATE TABLE or CREATE VIEW statement, and the table name or view name specified already exists.
42S0242S02 基表或视图找不到Base table or view not found *StatementText包含DROP TABLEDROP VIEW语句指定的表名或视图名称不存在。*StatementText contained a DROP TABLE or a DROP VIEW statement, and the specified table name or view name did not exist.

*StatementText包含ALTER TABLE语句,并指定的表名不存在。*StatementText contained an ALTER TABLE statement, and the specified table name did not exist.

*StatementText包含CREATE VIEW语句和表名称或视图不存在查询规范所定义的名称。*StatementText contained a CREATE VIEW statement, and a table name or view name defined by the query specification did not exist.

*StatementText包含CREATE INDEX语句,并指定的表名不存在。*StatementText contained a CREATE INDEX statement, and the specified table name did not exist.

*StatementText包含授予撤消语句指定的表名或视图名称不存在。*StatementText contained a GRANT or REVOKE statement, and the specified table name or view name did not exist.

*StatementText包含选择语句指定的表名或视图名称不存在。*StatementText contained a SELECT statement, and a specified table name or view name did not exist.

*StatementText包含删除插入,或更新语句,并指定的表名不存在。*StatementText contained a DELETE, INSERT, or UPDATE statement, and the specified table name did not exist.

*StatementText包含CREATE TABLE语句,并指定约束 (引用表而不正在创建) 中的表不存在。*StatementText contained a CREATE TABLE statement, and a table specified in a constraint (referencing a table other than the one being created) did not exist.

*StatementText包含CREATE SCHEMA语句指定的表名或视图名称不存在。*StatementText contained a CREATE SCHEMA statement, and a specified table name or view name did not exist.
42S1142S11 索引已存在Index already exists *StatementText包含CREATE INDEX语句,并指定的索引名称已存在。*StatementText contained a CREATE INDEX statement, and the specified index name already existed.

*StatementText包含CREATE SCHEMA语句,并指定的索引名称已存在。*StatementText contained a CREATE SCHEMA statement, and the specified index name already existed.
42S1242S12 找不到索引Index not found *StatementText包含DROP INDEX语句,并指定的索引名称不存在。*StatementText contained a DROP INDEX statement, and the specified index name did not exist.
42S2142S21 已存在的列Column already exists *StatementText包含ALTER TABLE语句,并在指定的列添加子句标识基表中的现有列,或不是唯一的。*StatementText contained an ALTER TABLE statement, and the column specified in the ADD clause is not unique or identifies an existing column in the base table.
42S2242S22 找不到列Column not found *StatementText包含CREATE INDEX语句,以及一个或多列列表中指定的名称不存在的列。*StatementText contained a CREATE INDEX statement, and one or more of the column names specified in the column list did not exist.

*StatementText包含授予撤消语句,并指定的列名称不存在。*StatementText contained a GRANT or REVOKE statement, and a specified column name did not exist.

*StatementText包含选择删除插入,或更新语句,并指定的列名称不存在。*StatementText contained a SELECT, DELETE, INSERT, or UPDATE statement, and a specified column name did not exist.

*StatementText包含CREATE TABLE语句,并指定约束 (引用表而不正在创建) 中的列不存在。*StatementText contained a CREATE TABLE statement, and a column specified in a constraint (referencing a table other than the one being created) did not exist.

*StatementText包含CREATE SCHEMA语句,并指定的列名称不存在。*StatementText contained a CREATE SCHEMA statement, and a specified column name did not exist.
4400044000 WITH CHECK OPTION 冲突WITH CHECK OPTION violation 自变量StatementText包含插入上查看的表执行的语句或派生自查看已通过指定的表的表WITH CHECK OPTION,这样,受影响的一个或多个行插入语句无法再查看表中存在。The argument StatementText contained an INSERT statement performed on a viewed table or a table derived from the viewed table that was created by specifying WITH CHECK OPTION, such that one or more rows affected by the INSERT statement will no longer be present in the viewed table.

自变量StatementText包含更新上查看的表执行的语句或派生自查看已通过指定的表的表WITH CHECK OPTION,这样,受影响的一个或多个行更新语句无法再查看表中存在。The argument StatementText contained an UPDATE statement performed on a viewed table or a table derived from the viewed table that was created by specifying WITH CHECK OPTION, such that one or more rows affected by the UPDATE statement will no longer be present in the viewed table.
HY000HY000 常规错误General error 有关其中没有任何特定的 SQLSTATE 和为其定义任何特定于实现的 SQLSTATE 出错。An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. 返回的错误消息SQLGetDiagRec*MessageText缓冲区描述错误以及其原因。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 异步处理的已启用StatementHandleAsynchronous processing was enabled for the StatementHandle. 调用该函数,和之前执行完毕SQLCancelSQLCancelHandle上调用了StatementHandleThe function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle. 然后在再次调用该函数StatementHandleThen the function was called again on the StatementHandle.

调用该函数,和之前执行完毕SQLCancelSQLCancelHandle上调用了StatementHandle来自不同线程中多线程应用程序。The 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 (DM) *StatementText是空指针。(DM) *StatementText 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. 此异步函数仍在执行时SQLExecDirect调用函数。This asynchronous function was still executing when the SQLExecDirect function was called.

(数据挖掘) SQLExecuteSQLExecDirect,或SQLMoreResults曾为StatementHandle和返回 SQL_PARAM_DATA_可用。(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.

(数据挖掘) SQLExecuteSQLExecDirectSQLBulkOperations,或者SQLSetPos曾为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.
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) 参数TextLength小于或等于为 0 但不是等于 SQL_NTS。(DM) The argument TextLength was less than or equal to 0 but not equal to SQL_NTS.

参数值,设置SQLBindParameter、 是空指针和参数长度值不是 0,SQL_NULL_DATA,SQL_DATA_AT_EXEC,SQL_DEFAULT_PARAM,或小于或等于 SQL_LEN_DATA_AT_EXEC_OFFSET。A parameter value, set with SQLBindParameter, was a null pointer, and the parameter length value was not 0, SQL_NULL_DATA, SQL_DATA_AT_EXEC, SQL_DEFAULT_PARAM, or less than or equal to SQL_LEN_DATA_AT_EXEC_OFFSET.

参数值,设置SQLBindParameter、 不是空指针; C 数据类型为 SQL_C_BINARY 或 SQL_C_CHAR; 和参数长度值是小于 0,但不是 SQL_NTS、 SQL_NULL_DATA、 SQL_DATA_AT_EXEC、 SQL_DEFAULT_参数,或小于或等于 SQL_LEN_DATA_AT_EXEC_OFFSET。A parameter value, set with SQLBindParameter, was not a null pointer; the C data type was SQL_C_BINARY or SQL_C_CHAR; and the parameter length value was less than 0 but was not SQL_NTS, SQL_NULL_DATA, SQL_DATA_AT_EXEC, SQL_DEFAULT_PARAM, or less than or equal to SQL_LEN_DATA_AT_EXEC_OFFSET.

参数长度值受SQLBindParameter为设置为 SQL_DATA_AT_EXEC; 的 SQL 类型为 SQL_LONGVARCHAR、 SQL_LONGVARBINARY、 或 long 数据源特定的数据类型; 和 SQL_NEED_LONG_DATA_LEN 信息在键入SQLGetInfo是"Y"。A parameter length value bound by SQLBindParameter was set to SQL_DATA_AT_EXEC; the SQL type was either SQL_LONGVARCHAR, SQL_LONGVARBINARY, or a long data source-specific data type; and the SQL_NEED_LONG_DATA_LEN information type in SQLGetInfo was "Y".
HY105HY105 无效的参数类型Invalid parameter type 为参数指定的值InputOutputTypeSQLBindParameter SQL_PARAM_OUTPUT,而该参数是输入的参数。The value specified for the argument InputOutputType in SQLBindParameter was SQL_PARAM_OUTPUT, and the parameter was an input parameter.
HY109HY109 无效的游标位置Invalid cursor position *StatementText包含和定位的 update 或 delete 语句,光标被定位 (通过SQLSetPosSQLFetchScroll) 上的行已删除或无法提取。*StatementText contained a positioned update or delete statement, and the cursor was positioned (by SQLSetPos or SQLFetchScroll) on a row that had been deleted or could not be fetched.
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 驱动程序或数据源不支持 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 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

应用程序调用SQLExecDirect将 SQL 语句发送到数据源。The application calls SQLExecDirect to send an SQL statement to the data source. 有关直接执行的详细信息,请参阅直接执行For more information about direct execution, see Direct Execution. 驱动程序修改该语句以使用 SQL 数据源使用的窗体,然后将其提交到数据源。The driver modifies the statement to use the form of SQL used by the data source and then submits it to the data source. 具体而言,该驱动程序将修改用于定义某些功能在 SQL 中的转义序列。In particular, the driver modifies the escape sequences used to define certain features in SQL. 转义序列的语法,请参阅ODBC 中的转义序列For the syntax of escape sequences, see Escape Sequences in ODBC.

应用程序可以在 SQL 语句中包含一个或多个参数标记。The application can include one or more parameter markers in the SQL statement. 若要包含的参数标记,应用程序,请嵌入到 SQL 语句中的相应位置的问号 (?)。To include a parameter marker, the application embeds a question mark (?) into the SQL statement at the appropriate position. 有关参数的信息,请参阅语句参数For information about parameters, see Statement Parameters.

如果 SQL 语句是选择语句,如果应用程序中调用SQLSetCursorName以将游标与语句相关联,然后驱动程序将使用指定的游标。If the SQL statement is a SELECT statement and if the application called SQLSetCursorName to associate a cursor with a statement, then the driver uses the specified cursor. 否则,该驱动程序生成的游标名称。Otherwise, the driver generates a cursor name.

如果数据源在手动提交模式下 (需要显式事务启动),并且尚未启动事务,驱动程序将启动一个事务发送的 SQL 语句之前。If the data source is in manual-commit mode (requiring explicit transaction initiation) and a transaction has not already been initiated, the driver initiates a transaction before it sends the SQL statement. 有关详细信息,请参阅手动提交模式For more information, see Manual-Commit Mode.

如果应用程序使用SQLExecDirect提交提交回滚语句,它不会 DBMS 产品之间的互操作性。If an application uses SQLExecDirect to submit a COMMIT or ROLLBACK statement, it will not be interoperable between DBMS products. 若要提交或回滚事务,应用程序调用SQLEndTranTo commit or roll back a transaction, an application calls SQLEndTran.

如果SQLExecDirect遇到执行时数据参数,它将返回 SQL_NEED_DATA。If SQLExecDirect encounters a data-at-execution parameter, it returns SQL_NEED_DATA. 应用程序发送的数据使用SQLParamDataSQLPutDataThe application sends the data using SQLParamData and SQLPutData. 请参阅SQLBindParameterSQLParamDataSQLPutData,以及发送长数据See SQLBindParameter, SQLParamData, SQLPutData, and Sending Long Data.

如果SQLExecDirect执行搜索的 update、 insert 或 delete 语句,但不影响任何行在数据源,调用SQLExecDirect返回 sql_no_data 为止。If SQLExecDirect executes a searched update, insert, or delete statement that does not affect any rows at the data source, the call to SQLExecDirect returns SQL_NO_DATA.

如果将 SQL_ATTR_PARAMSET_SIZE 语句属性的值大于 1,并且 SQL 语句中包含至少一个参数标记, SQLExecDirect将执行的每组参数值从一次的 SQL 语句指向数组ParameterValuePointer调用中的参数SQLBindParameterIf the value of the SQL_ATTR_PARAMSET_SIZE statement attribute is greater than 1 and the SQL statement contains at least one parameter marker, SQLExecDirect will execute the SQL statement once for each set of parameter values from the arrays pointed to by the ParameterValuePointer argument in the call to SQLBindParameter. 有关详细信息,请参阅参数值数组For more information, see Arrays of Parameter Values.

如果书签被打开,并且执行的查询不能支持书签,则驱动程序应尝试强制为通过更改属性值并返回 SQLSTATE 01S02 支持书签环境 (选项值已更改)。If bookmarks are turned on and a query is executed that cannot support bookmarks, the driver should attempt to coerce the environment to one that supports bookmarks by changing an attribute value and returning SQLSTATE 01S02 (Option value changed). 如果不能更改的属性,则驱动程序应返回 SQLSTATE 为 HY024 (无效的属性值)。If the attribute cannot be changed, the driver should return SQLSTATE HY024 (Invalid attribute value).

备注

当使用连接池时,应用程序必须执行 SQL 语句,如更改数据库或数据库的上下文使用_数据库_语句在 SQL Server 中,这会更改使用数据源的目录。When using connection pooling, an application must not execute SQL statements that change the database or the context of the database, such as the USE database statement in SQL Server, which changes the catalog used by a data source.

代码示例Code Example

请参阅SQLBindColSQLGetData,并示例 ODBC 程序See SQLBindCol, SQLGetData, and Sample ODBC Program.

有关信息For information about 请参阅See
将缓冲区绑定到结果集中的列Binding a buffer to a column in a result set SQLBindCol 函数SQLBindCol Function
取消语句处理Canceling statement processing SQLCancel 函数SQLCancel Function
执行提交或回滚操作Executing a commit or rollback operation SQLEndTran 函数SQLEndTran Function
执行已准备的 SQL 语句Executing a prepared SQL statement SQLExecute 函数SQLExecute Function
正在提取多行数据Fetching multiple rows of data SQLFetch 函数SQLFetch Function
提取的数据块或滚动浏览结果集Fetching a block of data or scrolling through a result set SQLFetchScroll 函数SQLFetchScroll Function
返回游标名称Returning a cursor name SQLGetCursorName 函数SQLGetCursorName Function
正在提取部分或全部的数据列Fetching part or all of a column of data SQLGetData 函数SQLGetData Function
返回下一个参数将数据发送用于Returning the next parameter to send data for SQLParamData 函数SQLParamData Function
准备执行的语句Preparing a statement for execution SQLPrepare 函数SQLPrepare Function
在执行时发送参数数据Sending parameter data at execution time SQLPutData 函数SQLPutData Function
设置游标名称Setting a cursor name SQLSetCursorName 函数SQLSetCursorName Function
设置语句属性Setting a statement attribute SQLSetStmtAttr 函数SQLSetStmtAttr Function

请参阅See Also

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