Home > Archive > MS SQL Server ODBC > April 2005 > When does SQLPrepare validate table name









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author When does SQLPrepare validate table name
CompWiz

2005-04-12, 8:23 pm

In SQL2k if I call SQLPrepare with the following select statement:

SELECT * FROM sometable

where sometable doesnt exist, SQLPrepare doesnt return any error.
However I have had reports that this fails under SQL7. Should
SQLPrepare fail in this case? or is there some option that would need
to be turned on?

I am using version 2000.81.9031.38 of the sql server odbc driver.

Thanks

Warren Read

2005-04-20, 8:23 pm

One of the SQL 8.0 enhancements was to automatically defer Preparing a
statement until either the metadata was requested or a SQLExecute is called.

To restore your application to expect SQL 7.0 behavior of getting an error
at SQLPrepare time you'll need to call:

SQLSetStmtAttr(hstmt
, SQL_SOPT_SS_DEFER_PR
EPARE, (SQLPOINTER)SQL_DP_O
FF,
SQL_IS_UINTEGER)

To switch back to SQL 8.0 behavior (the default), call:

SQLSetStmtAttr(hstmt
, SQL_SOPT_SS_DEFER_PR
EPARE, (SQLPOINTER)SQL_DP_O
N,
SQL_IS_UINTEGER)

~Warren


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com