Specification: | DB2 CLI 1.1 | ODBC 1.0 | ISO CLI |
SQLExecDirect() directly executes the specified SQL statement. The statement can be executed only once.
Syntax
SQLRETURN SQLExecDirect (SQLHSTMT StatementHandle, /* hstmt */ SQLCHAR *FAR StatementText, /* szSqlStr */ SQLINTEGER TextLength); /* cbSqlStr */
Function arguments
Table 44. SQLExecDirect arguments
Data type | Argument | Use | Description |
---|---|---|---|
SQLHSTMT | StatementHandle | input | Statement handle. |
SQLCHAR * | StatementText | input | SQL statement string. |
SQLINTEGER | TextLength | input | Length of the contents of StatementText argument. The length must be set to either the exact length of the statement, or if the statement is null-terminated, set to SQL_NTS. |
Usage
The SQL statement string cannot contain parameter markers.
Return codes
SQL_NO_DATA_FOUND is returned if the SQL statement is a Searched UPDATE or Searched DELETE and no rows satisfy the search condition.
Diagnostics
Table 45. SQLExecDirect SQLSTATEs
SQLSTATE | Description | Explanation |
---|---|---|
22003 | Numeric value out of range. | A numeric value assigned to a numeric type column caused truncation of the whole part of the number, either at the time of assignment or in computing an intermediate result. |
42xxx | Syntax error or access rule violation. | 42xxx SQLSTATEs indicate a variety of syntax or access problems with the statement. xxx refers to any SQLSTATE with that class code. Example: 42xxx refers to any SQLSTATE in the 42 class. |
58004 | Unexpected system failure. | Unrecoverable system error. |
HY001 | Memory allocation failure. | DB2 CLI is unable to allocate memory required to support execution or completion of the function. |
HY009 | Invalid argument value. | StatementText is a null pointer. |
HY013 | Unexpected memory handling error. | DB2 CLI is unable to access memory required to support execution or completion of the function. |
HY014 | No more handles. | DB2 CLI is unable to allocate a handle due to internal resources. |
HY090 | Invalid string or buffer length. | The argument TextLength is less than one but not equal to SQL_NTS. |
Restrictions
None.
Related reference