Please enable JavaScript to view this site.

ESL Documentation

Level 2 subroutine

Return the exact SQL string as translated by the driver.

call EDSNativeSql(HDBC_IV,SQLSTMTIN_SV,SQLSTMTOUT_SV) 

HDBC_IV An input integer value indicating the connection handle.

SQLSTMTIN_SV An input string value containing the SQL text string to be translated.

SQLSTMTOUT_SV An output string value containing the translated SQL string.

Description

This subroutine is useful if your application uses escape sequences to transmit database-specific text. If the SQL string does not fit in the output buffer, the driver stores the maximum number of bytes in SQLSTMTOUT_SV, and returns EDS_SUCCESS_WITH_INFO.

Return Values

EDSNativeSql returns EDS_SUCCESS, EDS_ERROR, EDS_INVALID_HANDLE, or EDS_SUCCESS_WITH_INFO.

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

 

The following table lists possible SQLSTATE values:

SQL

STATE

Error

Description

08003

Connection not open

The connection handle was not in a connected state.

37000

Syntax error

The argument SQLSTMTIN_SV contained a access violation SQL statement that was not preparable or contained a syntax error.

IM001

Driver does not support the function

The driver associated with the connection support this handle does not . 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.

S1009

Invalid argument

The argument SQLSTMTIN_SV was a null value pointer.

Example

The following are examples of what EDSNativeSql might return for the following input SQL string containing the scalar function CONVERT. Assume that the column “empid” is of type INTEGER in the data source:

SELECT { fn CONVERT ( empid, SQL_SMALLINT) } FROM employee 

A driver for SQLServer will return the following translated SQL string:

SELECT convert ( smallint, empid) FROM employee