Please enable JavaScript to view this site.

ESL Documentation

Core subroutine

Allocate a statement handle.

call EDSAllocStmt(HDBC_IV, HSTMT_IV ) 

HDBC_IV An input integer value indicating the connection handle.

HSTMT_IV An output integer value indicating the statement handle.

Description

When your application passes the address of a variable to EDSAllocStmt, EDS allocates memory and stores the value of the associated handle into the variable. Your application can then pass the HSTMT_IV value in all subsequent calls that require a statement handle.

Before calling EDSAllocStmt, your application must successfully establish a connection. Your application must call EDSAllocStmt before submitting SQL statements. If HSTMT_IV references a statement handle that has been previously allocated, EDS returns without processing the call.

Return Values

EDSAllocStmt returns EDS_SUCCESS, EDS_INVALID_HANDLE, or EDS_ERROR.

If EDS returns EDS_ERROR for EDSAllocStmt, it sets HSTMT_IV to EDS_NULL_HSTMT. Your application can then obtain additional information by calling EDSError with HENV_IV, HDBC_IV, and EDS_NULL_HSTMT.

If your application calls EDSAllocStmt with a null statement handle, a subsequent call to EDSError will return SQLSTATE value S1009 (invalid argument value).

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

The following table lists possible SQLSTATE values.

SQL

STATE

Error

Description

08003

Connection not open

The connection specified by the HDBC_IV argument was not open. The connection process must be completed successfully (and the connection must be open) for the driver to allocate a statement handle.

IM001

Driver does not support this function

The driver associated with HDBC_IV 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 memory for the statement handle.

See Also

EDSPrepare, EDSExecute, and EDSExecDirect submit SQL statements.

EDSFreeStmt frees the statement handle (the opposite of EDSAllocStmt).