Please enable JavaScript to view this site.

ESL Documentation

Core subroutine

Prepare and execute a statement.

call EDSExecDirect(HSTMT_IV,SQLSTMT_SV ) 

HSTMT_IV An input integer value indicating the statement handle.

SQLSTMT_SV An input string value containing the SQL statement to be executed.

Description

EDSExecDirect is the fastest way to submit a SQL string for one-time execution. The ESL application calls EDSExecDirect to send a SQL string to the driver. The driver then submits the SQL string to the data source.

If the SQL statement is a SELECT statement, and if your application called EDSSetCursorName to associate a cursor with a statement handle, then the driver uses the specified cursor. Otherwise, the driver generates a cursor name.

If the data source is in manual-commit mode (requiring explicit transaction initiation), and a transaction has not already been initiated, the driver begins a transaction prior to submitting the statement.

If your application uses EDSExecDirect to submit a COMMIT or ROLLBACK statement, it will not be interoperable between DBMS products.  To commit or roll back a transaction, call EDSTransact.

If EDSExecDirect encounters an EDS_DATA_AT_EXEC parameter, it returns EDS_NEED_DATA. Your application sends the data using EDSParamData and EDSPutData. See EDSSetParam, EDSParamOptions, EDSParamData, and EDSPutData for more information.

Some data sources return informational messages after processing SQL commands. For example, Microsoft SQL Server returns a message when the database context changes. When such information is returned to the driver, EDSExecDirect returns EDS_SUCCESS_WITH_INFO. Your application can call EDSError to retrieve the message.

Return Values

EDSExecDirect returns EDS_SUCCESS, EDS_SUCCESS_WITH_INFO, EDS_NEED_DATA, EDS_INVALID_HANDLE, or EDS_ERROR.

When EDSExecDirect returns EDS_ERROR, you can obtain an associated SQLSTATE value with more specific information by calling EDSError. The following table lists each typical SQLSTATE value and explains each one in the context of the command EDSExecDirect.

The following table lists possible SQLSTATE values.

SQL

STATE

Error

Description

01006

Privilege not revoked

The argument SQLSTMT_SV contained a REVOKE statement and the user did not have the specified privilege. (Function returns EDS_SUCCESS_WITH_INFO.)

07001

Wrong number of parameters

The number of parameters specified in EDSSetParam was less than the number of parameters in the SQL statement contained in the argument SQLSTMT_SV.

08S01

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.

21S01

Insert value list does not match column list

The argument SQLSTMT_SV contained an INSERT statement and the number of values to be inserted did not match the degree of the derived table.

21S02

Degree of derived table does not match column list

The argument SQLSTMT_SV contained a CREATE VIEW statement and the number of names specified is not the same degree as the derived table defined by the query specification.

22001

String data right truncation

The argument SQLSTMT_SV contained a SQL statement that contained a character parameter or literal and the value exceeded the maximum length of the associated table column.

22003

Numeric value

The argument SQLSTMT_SV contained a SQL out of range statement that contained a numeric parameter or literal and the value caused the whole part of the number to be truncated when assigned to the associated table column.

22005

Error in assignment

The argument SQLSTMT_SV contained a SQL statement that contained a parameter or literal and the value was incompatible with the data type of the associated table column.

22008

Datetime field

The argument SQLSTMT_SV contained a SQL overflow statement that contained a date, time, or timestamp parameter or literal and the value was, respectively, an invalid date, time, or timestamp.

22012

Division by zero

The argument SQLSTMT_SV contained a SQL statement that contained an arithmetic expression that caused division by zero.

22026

String data, length

The data sent for a parameter was less than the mismatch length of data required. Typically, returned for EDS_SQL_LONGVARCHAR or EDS_SQL_LONGVARBINARY.

23000

Integrity constraint violation

The argument SQLSTMT_SV contained a SQL statement that contained a parameter or literal. 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.

24000

Invalid cursor state

Results were pending on the statement handle from a previous SELECT statement or a cursor associated with the statement handle had not been closed.

34000

Invalid cursor

The argument SQLSTMT_SV contained a name dynamic positioned DELETE or a dynamic positioned UPDATE and the cursor referenced by the statement being prepared was not open.

37000

Syntax error or access violation

The argument SQLSTMT_SV contained a SQL statement that was not preparable or contained a syntax error.

40001

Serialization failure

The transaction to which the SQL statement contained in the argument SQLSTMT_SV belonged was terminated to prevent deadlock.

42000

Syntax error or access violation

The user did not have permission to execute the SQL statement contained in the argument SQLSTMT_SV.

IM001

Driver does not support this function

The driver associated with the statement handle does not support the function.

S0001

Base table or view already exists

The argument SQLSTMT_SV contained a CREATE TABLE or CREATE VIEW statement and the table name or view name specified already exists.

S0002

Table or view not found

The argument SQLSTMT_SV contained a DROP TABLE or a DROP VIEW statement and the specified table name or view name did not exist. The argument SQLSTMT_SV contained an ALTER TABLE statement and the specified table name did not exist. The argument SQLSTMT_SV contained a CREATE VIEW statement and a table name or view name defined by the query specification did not exist. The argument SQLSTMT_SV contained a CREATE INDEX statement and the specified table name did not exist. The argument SQLSTMT_SV contained a GRANT or REVOKE statement and the specified table name or view name did not exist. The argument SQLSTMT_SV contained a SELECT statement and a specified table name or view name did not exist. The argument SQLSTMT_SV contained a DELETE, INSERT, or UPDATE statement and the specified table name did not exist.

S0011

Index already exists

The argument SQLSTMT_SV contained a CREATE INDEX statement and the specified index name already existed.

S0012

Index not found

The argument SQLSTMT_SV contained a DROP INDEX statement and the specified index name did not exist.

S0021

Column already exists

The argument SQLSTMT_SV 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.

S0022

Column not found

The argument SQLSTMT_SV contained a CREATE INDEX statement and one or more of the column names specified in the column list did not exist. The argument SQLSTMT_SV contained a GRANT or REVOKE statement and the specified column name did not exist. The argument SQLSTMT_SV contained a SELECT, DELETE, INSERT, or UPDATE statement and the specified column name did not exist.

S1000

General error

An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by EDSError in the argument ERRORTEXT describes the error and its cause.

S1001

Memory allocation failure

The driver was unable to allocate memory required to support execution or completion of the function.

S1008

Operation cancelled

Asynchronous processing was enabled for the statement handle. The function was called and before it completed execution, EDSCancel was called on the statement handle. Then the function was called again on the statement handle.

S1009

Invalid argument

The argument SQLSTMT_SV was a null value. value

S1010

Function sequence

An asynchronously executing function (not this error one) was called for the statement handle and was still executing when this function was called.

S1T00

Timeout expired

The timeout period expired before the data source returned the result set. The timeout period is set through EDSSetStmtOption, EDS_QUERY_TIMEOUT.

See Also

EDSBindCol assigns an ESL variable for a column in the result set.
EDSCancel cancels statement processing.
EDSExecute executes a prepared statement.
EDSFetch, EDSGetData, and EDSExtendedFetch retrieve data.
EDSGetCursorName returns a cursor name.
EDSPrepare prepares a statement for later execution.
EDSPutData and EDSParamData send large data values.
EDSSetCursorName specifies a cursor name.
EDSSetParam assigns an ESL variable for a parameter.
EDSSetStmtOption specifies asynchronous execution.
EDSTransact executes a commit or rollback operation.