Skip to content

Latest commit

 

History

History
84 lines (60 loc) · 2.2 KB

SQLNativeSql.md

File metadata and controls

84 lines (60 loc) · 2.2 KB

Home

Function name : SQLNativeSql

Group: ODBC API - Library: odbc32


SQLNativeSql returns the SQL string as modified by the driver. SQLNativeSql does not execute the SQL statement.


Code examples:

Using vendor-neutral SQL constructs

Declaration:

SQLRETURN SQLNativeSql(
	SQLHDBC      ConnectionHandle,
	SQLCHAR *    InStatementText,
	SQLINTEGER   TextLength1,
	SQLCHAR *    OutStatementText,
	SQLINTEGER   BufferLength,
	SQLINTEGER * TextLength2Ptr);  

FoxPro declaration:

DECLARE SHORT SQLNativeSql IN odbc32;
	INTEGER  ConnectionHandle,;
	STRING    InStatText,;
	INTEGER   TextLen1,;
	STRING  @ OutStatText,;
	INTEGER   BufferLen,;
	INTEGER @ TextLen2Ptr
  

Parameters:

ConnectionHandle [Input] Connection handle.

InStatementText [Input] SQL text string to be translated.

TextLength1 [Input] Length of *InStatementText text string.

OutStatementText [Output] Pointer to a buffer in which to return the translated SQL string.

BufferLength [Input] Length of the *OutStatementText buffer.

TextLength2Ptr [Output] Pointer to a buffer in which to return the total number of bytes (excluding the null-termination byte) available to return in *OutStatementText.


Return value:

SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.


Comments:

Not all ODBC drivers support this function. As well not all of them support escape sequences. Both are supported by MS Access (MSDAO) and MS SQL Server. To my disappointment I found this functionality not supported by Visual FoxPro ODC driver (ver. 6.01.8629.01)

SQLNativeSql returns the SQL string as modified by the driver. SQLNativeSql does not execute the SQL statement..

Some links on vendor-neutral constructs:
Escape Sequences in ODBC
Using Interoperable SQL. By Ken North