SQLExecute 函数SQLExecute Function

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

摘要Summary
如果语句中存在任何参数标记, SQLExecute将使用参数标记变量的当前值执行已准备的语句。SQLExecute executes a prepared statement, using the current values of the parameter marker variables if any parameter markers exist in the statement.

语法Syntax

  
SQLRETURN SQLExecute(  
     SQLHSTMT     StatementHandle);  

参数Arguments

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

返回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

SQLExecute返回 SQL_ERROR 或 SQL_SUCCESS_WITH_INFO 时,可以通过使用HandleType的 SQL_HANDLE_STMT 和StatementHandle句柄调用SQLGetDiagRec来获取关联的 SQLSTATE 值。When SQLExecute 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. 下表列出了通常由SQLExecute返回的 SQLSTATE 值,并对该函数的上下文中的每个值进行了说明:"(DM)" 表示法位于驱动程序管理器返回的 SQLSTATEs 的说明之前。The following table lists the SQLSTATE values commonly returned by SQLExecute 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.)
0100101001 游标操作冲突Cursor operation conflict StatementHandle关联的预定义语句包含定位的 update 或 delete 语句,并且未更新或删除任何行或多行。The prepared statement associated with the StatementHandle contained a positioned update or delete statement, and no rows or more than one row were updated or deleted. (有关多行更新的详细信息,请参阅SQLSetStmtAttr中的 SQL_ATTR_SIMULATE_CURSOR属性的说明。)(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 值NULL value eliminated in set function StatementHandle关联的预定义语句包含集函数(例如AVGMAXMIN等),但不包含COUNT SET 函数,并且在应用函数之前消除了 NULL 参数值。The prepared statement associated with StatementHandle 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 为 output 参数返回的字符串或二进制数据导致截断非空白字符或非空的二进制数据。String or binary data returned for an 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 StatementHandle关联的预定义语句是REVOKE语句,而用户没有指定的权限。The prepared statement associated with the StatementHandle was 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 StatementHandle关联的预定义语句是GRANT语句,并且用户无法被授予指定的权限。The prepared statement associated with the StatementHandle 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. 可以更改的语句属性有: 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_CURSOR。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, and 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中指定的参数数目小于* StatementText中包含的 SQL 语句中的参数数量。The 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中指定的参数数目大于 *StatementText中包含的 SQL 语句中的参数数量。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 绑定参数的SQLBindParameter中的ValueType参数标识的数据值无法转换为SQLBindParameterParameterType参数所标识的数据类型。The 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 的参数返回的数据值无法转换为SQLBindParameterValueType参数标识的数据类型。The 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,且在SQLBindParameter中指定的* StrLen_or_IndPtr不等于 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 的,并且相应的参数不是 ODBC 规范过程调用的参数。A parameter value, set with SQLBindParameter, was SQL_DEFAULT_PARAM, and the corresponding parameter was not a parameter for an ODBC canonical procedure invocation.
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.
21S0221S02 派生表的等级与列列表不匹配Degree of derived table does not match column list StatementHandle关联的预定义语句包含CREATE VIEW语句,而非限定的列列表(sql 语句的列标识符参数中为视图指定的列数)所包含的名称多于由 sql 语句的查询规范参数定义的派生表中的列数。The prepared statement associated with the StatementHandle 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) or non-null (binary) characters or bytes.
2200222002 需要指示器变量,但未提供Indicator variable required but not supplied NULL 数据已绑定到一个输出参数,该参数的StrLen_or_IndPtrSQLBindParameter设置为 null 指针。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 StatementHandle关联的预定义语句包含绑定的数值参数,而参数值导致在分配给关联表列时要截断的数字部分(而不是小数部分)。The prepared statement associated with the StatementHandle contained a bound numeric parameter, and the parameter 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 Datetime 格式无效Invalid datetime format StatementHandle关联的预定义语句包含一个 SQL 语句,该语句包含一个作为绑定参数的日期、时间或时间戳结构,并且参数分别为无效的日期、时间或时间戳。The prepared statement associated with the StatementHandle 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 StatementHandle关联的预定义语句包含一个 SQL 语句,该语句包含一个日期时间表达式,该表达式在计算时导致日期、时间或时间戳结构无效。The prepared statement associated with the StatementHandle 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 StatementHandle关联的预定义语句包含导致被零除的算术表达式。The prepared statement associated with the StatementHandle 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 类型的参数数据,且 interval 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.

将是精确数值或间隔 SQL 类型的输入/输出或输出参数分配给 interval C 类型会导致有效位丢失。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.

如果将输入/输出参数或输出参数分配给 interval 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.

返回 input/output 或 output 参数时,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 StatementHandle关联的预定义语句包含WHERE子句中包含转义LIKE谓词,并且转义字符后面的转义符的长度不等于1。The prepared statement associated with StatementHandle 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 StatementHandle关联的预定义语句包含WHERE子句中的 "LIKE 模式值转义转义符",并且模式值中转义符后面的字符不是 "%" 或 ""。The prepared statement associated with StatementHandle 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 StatementHandle关联的预定义语句包含参数。The prepared statement associated with the StatementHandle contained a parameter. 对于在关联的表列中定义为 NOT NULL 的列,参数值为 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 游标由SQLFetchSQLFetchScroll定位在StatementHandle上。A 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.

StatementHandle上打开了游标。A cursor was open on the StatementHandle.

StatementHandle关联的预定义语句包含定位的 update 或 delete statemen,t,游标位于结果集的开头之前或结果集结束之后。The prepared statement associated with the StatementHandle contained a positioned update or delete statemen,t and the cursor was positioned before the start of the result set or after the end of the result set.
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 用户没有执行与StatementHandle关联的预定义语句的权限。The user did not have permission to execute the prepared statement associated with the StatementHandle.
4400044000 WITH CHECK OPTION 冲突WITH CHECK OPTION violation StatementHandle关联的预定义语句包含对已查看的表或从已查看的表(通过指定with CHECK OPTION创建)执行的INSERT语句,这样,在所查看的表中将不再存在受该insert语句影响的一个或多个行。The prepared statement associated with StatementHandle 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.

StatementHandle关联的预定义语句包含对已查看的表或从已查看表派生的表的UPDATE语句,该语句是通过指定with CHECK OPTION创建的,因此,由UPDATE语句影响的一个或多个行将不再出现在查看的表中。The prepared statement associated with the StatementHandle 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. 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.
HY010HY010 函数序列错误Function sequence error (DM)为与StatementHandle关联的连接句柄调用了异步执行的函数。(DM) An asynchronously executing function was called for the connection handle that is associated with the StatementHandle. 调用SQLExecute函数时,此异步函数仍在执行。This asynchronous function was still executing when the SQLExecute function was called.

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

(DM)为StatementHandle调用了异步执行的函数(而不是此函数),并且在调用此函数时仍在执行。(DM) An asynchronously executing function (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) StatementHandle未准备好。(DM) The StatementHandle was not prepared.
HY013HY013 内存管理错误Memory management error 未能处理函数调用,原因可能是由于内存不足而无法访问基础内存对象。The function call could not be processed because the underlying memory objects could not be accessed, possibly because of low memory conditions.
HY090HY090 字符串或缓冲区长度无效Invalid string or buffer length 使用SQLBindParameter设置的参数值为 null 指针,并且参数的长度值不是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设置的参数值不是 null 指针;C 数据类型为 SQL_C_BINARY 或 SQL_C_CHAR;参数长度值小于0,但未 SQL_NTS、SQL_NULL_DATA、SQL_DEFAULT_PARAM 或 SQL_DATA_AT_EXEC,或者小于或等于 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_DEFAULT_PARAM, or SQL_DATA_AT_EXEC, or less than or equal to SQL_LEN_DATA_AT_EXEC_OFFSET.

SQLBindParameter绑定的参数长度值设置为 SQL_DATA_AT_EXEC;SQL 类型是 SQL_LONGVARCHAR、SQL_LONGVARBINARY 或 long 特定于数据源的数据类型;SQLGetInfo中的 SQL_NEED_LONG_DATA_LEN 信息类型为 "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 SQLBindParameter中的参数InputOutputType指定的值 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 预定义的语句是定位的 update 或 delete 语句,并且游标已被删除或无法提取的行定位(通过SQLSetPosSQLFetchScroll)。The prepared statement was 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.

SQLExecute可以返回SQLPrepare返回的任何 SQLSTATE,具体取决于数据源何时计算与该语句关联的 SQL 语句。SQLExecute can return any SQLSTATE that can be returned by SQLPrepare, based on when the data source evaluates the SQL statement associated with the statement.

说明Comments

SQLExecute执行由SQLPrepare准备的语句。SQLExecute executes a statement prepared by SQLPrepare. 在应用程序从对SQLExecute的调用中处理或放弃结果后,应用程序可以使用新参数值再次调用SQLExecuteAfter the application processes or discards the results from a call to SQLExecute, the application can call SQLExecute again with new parameter values. 有关已准备执行的详细信息,请参阅准备执行For more information about prepared execution, see Prepared Execution.

若要多次执行select语句,应用程序必须在 reexecuting select语句之前调用SQLCloseCursorTo execute a SELECT statement more than once, the application must call SQLCloseCursor before reexecuting the SELECT statement.

如果数据源处于手动提交模式(需要显式事务启动),并且尚未启动事务,则驱动程序将在发送 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 Transactions.

如果应用程序使用SQLPrepare做好准备,并SQLExecute提交提交回滚语句,则它在 DBMS 产品之间将无法互操作。If an application uses SQLPrepare to prepare and SQLExecute to submit a COMMIT or ROLLBACK statement, it will not be interoperable between DBMS products. 若要提交或回滚事务,请调用SQLEndTranTo commit or roll back a transaction, call SQLEndTran.

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

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

如果 SQL_ATTR_PARAMSET_SIZE 语句特性的值大于1,且 SQL 语句至少包含一个参数标记,则SQLExecute会在对SQLBindParameter的调用中由* *ParameterValuePtr*参数指向的数组中的每组参数值执行一次 SQL 语句。If the value of the SQL_ATTR_PARAMSET_SIZE statement attribute is greater than 1 and the SQL statement contains at least one parameter marker, SQLExecute executes the SQL statement once for each set of parameter values in the arrays pointed to by the *ParameterValuePtr argument in the calls to SQLBindParameter. 有关详细信息,请参阅参数值的数组For more information, see Arrays of Parameter Values.

如果启用书签并且执行的查询不支持书签,则驱动程序应尝试将环境强制转换为支持书签的环境,方法是更改属性值并返回 SQLSTATE 01S02 (选项值已更改)。If bookmarks are enabled 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 中使用的_database_语句,这将更改数据源所使用的目录。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

请参阅SQLBindParameterSQLBulkOperationsSQLPutDataSQLSetPosSee SQLBindParameter, SQLBulkOperations, SQLPutData, and SQLSetPos.

有关以下方面的信息For information about 查看See
将缓冲区绑定到结果集中的列Binding a buffer to a column in a result set SQLBindCol 函数SQLBindCol Function
正在取消语句处理Canceling statement processing SQLCancel 函数SQLCancel Function
关闭游标Closing the cursor SQLCloseCursor 函数SQLCloseCursor Function
执行提交或回滚操作Executing a commit or rollback operation SQLEndTran 函数SQLEndTran Function
执行 SQL 语句Executing an SQL statement SQLExecDirect 函数SQLExecDirect Function
提取多行数据Fetching multiple rows of data SQLFetch 函数SQLFetch Function
提取数据块或滚动结果集Fetching a block of data or scrolling through a result set SQLFetchScroll Function(SQLFetchScroll 函数)SQLFetchScroll Function
释放语句句柄Freeing a statement handle SQLFreeStmt 函数SQLFreeStmt 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