Please enable JavaScript to view this site.

ESL Documentation

Core subroutine

Execute a prepared statement.

call EDSExecute(HSTMT_IV) 

HSTMT_IV An input integer value indicating the statement handle.

Description

To prepare and execute a statement with parameters, the ESL application must perform the following steps:

1.Call EDSPrepare to prepare the statement.

2.Call EDSSetParam to associate ESL variables with parameter markers.

3.Set parameter values.

4.Call EDSExecute.

The driver sends the SQL string to the data source, including any parameter values.

EDSExecute uses the current values of the parameter marker variables if any parameter markers exist in the statement.

Once your application processes or discards the results from a call to EDSExecute, your application can call EDSExecute again with new parameter values.

To execute a SELECT statement more than once, your application can call EDSFreeStmt with the EDS_CLOSE parameter before reissuing the SELECT statement.

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 string.

If your application uses EDSPrepare to prepare and EDSExecute 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 EDSExecute encounters a 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.

Return Values

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

When EDSExecute 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 EDSExecute.

The following table lists possible SQLSTATE values.

SQL

STATE

Error

Description

01006

Privilege not revoked

The prepared statement associated with the statement handle was REVOKE 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 prepared statement associated with the statement handle.

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.

22001

String data right truncation

The prepared statement associated with the statement handle contained a character parameter and the parameter value exceeded the maximum length of the associated table column.

22003

Numeric value out of range

The prepared statement associated with the statement handle contained a numeric parameter and the parameter value caused the whole part of the number to be truncated when assigned to the associated table column.

22005

Error in assignment

The prepared statement associated with the statement handle contained a parameter and the value was incompatible with the data type of the associated table column.

22008

Datetime field overflow

The prepared statement associated with the statement handle 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 prepared statement associated with the statement handle contained an arithmetic expression which caused division by zero.

23000

Integrity constraint violation

The prepared statement associated with the statement handle contained a parameter. 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.

40001

Serialization failure

The transaction to which the prepared statement associated with the statement handle belonged was terminated to prevent deadlock.

42000

Syntax error or access violation

The user did not have permission to execute the prepared statement associated with the statement handle.

IM001

Driver does not support this function

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

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 the 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.

S1010

Function sequence error

The specified statement handle was not in a prepared state. EDSExecute was called without first calling EDSPrepare. An asynchronously executing function (not this 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 defines an ESL variable for a column in a result set.
EDSCancel cancels statement processing.
EDSExecDirect executes a statement without preparing it first.
EDSExtendedFetch fetches a block of data or scrolls through a result set.
EDSFetch fetches a row of data.

EDSFreeStmt frees a statement handle.
EDSGetCursorName returns a cursor name.
EDSGetData fetches part or all of a column of data.
EDSPrepare prepares a statement prior to execution.
EDSPutData and EDSParamData send large data values.
EDSSetCursorName associates a cursor with a statement.
EDSSetParam defines an ESL variable for a parameter in a SQL statement.
EDSSetStmtOption sets a statement option.
EDSTransact executes a commit or rollback operation.