16.8.2 SQLExecDirect, SQLExecDirectW
- Organization of this subsection
(1) Function
This ODBC function executes a prepared SQL statement. If the SQL statement contains parameter markers, this ODBC function uses the current values of the parameter marker variables to execute the SQL statement. SQLExecDirect is the fastest way to issue an SQL statement for one-time execution.
(2) Format
-
For SQLExecDirect
SQLRETURN SQLExecDirect ( SQLHSTMT StatementHandle, /* In */ SQLCHAR * StatementText, /* In */ SQLINTEGER TextLength /* In */ )
-
For SQLExecDirectW
SQLRETURN SQLExecDirectW ( SQLHSTMT StatementHandle, /* In */ SQLWCHAR * StatementText, /* In */ SQLINTEGER TextLength /* In */ )
(3) Arguments
- StatementHandle
-
Specifies a statement handle.
Specify a value that was output by *OutputHandlePtr of SQLAllocHandle before this function is executed.
- StatementText
-
Specifies the SQL character string to be executed. A null pointer cannot be specified. Specify a character string consisting of at least one character. Comments (bracketed between /* and */) are not permitted within an SQL character string, but specifications bracketed between /*>> and <<*/ (for example, index specifications) are permitted within an SQL character string.
- TextLength
-
Specifies the length of *StatementText. The handling depends on the specified value, as explained in the following table:
Value specified in TextLength
Handling of TextLength
Integer value greater than 0
The specified data length from the beginning of *StatementText takes effect (in bytes for SQLExecDirect and in characters for SQLExecDirectW).
SQL_NTS
The value of TextLength is ignored, and from the beginning of *StatementText through NULL takes effect.
(4) Return value
This ODBC function returns SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA, SQL_ERROR, SQL_NEED_DATA, or SQL_INVALID_HANDLE.
(5) SQLSTATE
This ODBC function returns one of the following SQLSTATE values:
SQLSTATE |
Description |
Remarks |
Returned |
---|---|---|---|
01000 |
General warning |
-- |
N |
01001 |
Cursor operation conflict |
N |
|
01003 |
NULL value eliminated in set function |
N |
|
01004 |
Character string data was right-truncated |
Y |
|
01006 |
Privilege not revoked |
N |
|
01007 |
Privilege not granted |
N |
|
01S02 |
Option value changed |
N |
|
01S07 |
Fractional truncation |
N |
|
07002 |
COUNT field incorrect |
The number of parameters specified in SQLBindParameter does not match the number of dynamic parameters. |
Y |
07006 |
Restricted data type attribute violation |
-- |
N |
07S01 |
Invalid use of default parameter |
N |
|
08003 |
Connection does not exist |
Y |
|
08S01 |
Communication link failure |
N |
|
21S01 |
Insert value list does not match column list |
N |
|
21S02 |
Degree of derived table does not match column list |
N |
|
22001 |
Character string data was right-truncated |
Y |
|
22002 |
Required indicator variable not supplied |
N |
|
22003 |
Numeric value out of range |
Y |
|
22007 |
Invalid datetime format |
Y |
|
22008 |
Datetime field overflow |
Y |
|
22012 |
Division by zero |
N |
|
22015 |
Interval field overflow |
N |
|
22018 |
Invalid character value for cast specification |
Y |
|
22019 |
Invalid escape character |
N |
|
22025 |
Invalid escape sequence |
N |
|
23000 |
Integrity constraint violation |
N |
|
24000 |
Invalid cursor status |
Y |
|
34000 |
Invalid cursor name |
N |
|
3D000 |
Invalid catalog name |
N |
|
3F000 |
Invalid schema name |
N |
|
40001 |
Serialization failure |
N |
|
40003 |
Statement completion unknown |
N |
|
42000 |
Syntax error or access violation |
N |
|
42S01 |
Base table or view already exists |
N |
|
42S02 |
Base table or view not found |
N |
|
42S11 |
Index already exists |
N |
|
42S12 |
Index not found |
N |
|
42S21 |
Column already exists |
N |
|
42S22 |
Column not found |
N |
|
44000 |
WITH CHECK OPTION violation |
N |
|
5C002 |
Character encoding conversion error |
A character code that cannot be converted was detected. |
Y |
5C036 |
Data conversion error |
The contents of the requested input data are invalid. |
Y |
5C041 |
Unsupported data type error |
The driver does not support the specified data type. |
Y |
5C051 |
The text character string for an SQL statement exceeded 16,000,000 characters |
Even if the text character string for an SQL statement consists of 16,000,000 or fewer characters, the result after character encoding conversion by the driver manager might exceed 16,000,000 characters. SQLSTATE is also returned in such a case. |
Y |
HY000 |
General error |
-- |
N |
HY001 |
Memory allocation error |
Y |
|
HY003 |
Invalid C data type |
Y |
|
HY004 |
Invalid SQL data type |
Y |
|
HY008 |
Operation cancelled |
N |
|
HY009 |
Invalid use of null pointer |
Y |
|
HY010 |
Function sequence error |
Y |
|
HY013 |
Memory management error |
Y |
|
HY014 |
Invalid precision or scale value |
Y |
|
HY090 |
Invalid string or buffer length |
Y |
|
HY104 |
Invalid precision or scale value |
Y |
|
HY105 |
Invalid parameter type |
N |
|
HY109 |
Invalid cursor position |
N |
|
HYC00 |
Optional feature not implemented |
Y |
|
HYT00 |
Timeout expired |
N |
|
HYT01 |
Connection timeout expired |
N |
|
IM001 |
Driver does not support this function |
N |
- Legend:
-
Y: This SQLSTATE might be returned by the HADB ODBC driver.
N: This SQLSTATE is not returned by the HADB ODBC driver.
--: None
(6) Notes
-
Processing for handling Microsoft Access(R) Version 2.0 is not supported.
-
The bookmark feature is not supported.