INF: Cannot SQLPrepare() the Creation of Temporary ObjectsID: Q155818
|
If an ODBC application attempts to create a local temporary table or procedure in an SQL command issued using SQLPrepare() and SQLExecute(), subsequent references to the object might get errors that the object does not exist. This happens when the application or data source has specified that the driver should generate stored procedures to support SQLPrepare().
The Microsoft SQL Server ODBC driver can support the SQLPrepare()
SQLExecute() model of ODBC by generating a stored procedure on the
SQLPrepare() call and then executing that procedure when the application
calls SQLExecute(). This is controlled by either setting driver specific
SQLSetConnect() options as documented in the driver's documentation, or by
setting on the "Generate Stored Procedure for Prepared Statement" option
when defining the data source in the ODBC Administrator.
If an application with this option set on tries to create a local temporary
table or stored procedure using SQLPrepare() and SQLExecute(), the object
will not exist after the SQLExecute() command completes. For example, if an
application does:
SQLPrepare(hstmt,
"create table #sometable(cola int, colb char(8))",
SQL_NTS);
SQLExecute(hstmt);
SQLPrepare(hstmt,
"select * from authors into #sometable",
SQL_NTS);
SQLExecute(hstmt);
create procedure #ODBC#NNNNNNNN as
create table #sometable(cola int, colb char(8))
EXEC #ODBC#NNNNNNNN
SQLPrepare(hstmt,
"create table ##sometable(cola int, colb char(8))",
SQL_NTS);
SQLExecute(hstmt);
Keywords : kbnetwork SSrvStProc
Version : 2.65.0201
Platform : WINDOWS
Issue type :
Last Reviewed: April 1, 1999