Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

INFO: SQLState Returned by Microsoft Oracle ODBC Driver on Input Parameter Truncation


View products that this article applies to.

This article was previously published under Q306006

↑ Back to the top


Summary

When using an input parameter in a WHERE clause whose size is greater than the column size in the database, the Microsoft ODBC for Oracle driver returns SQL_SUCCESS_WITH_INFO on the SQLExecute call with a SQLState 01004.

↑ Back to the top


More information

In drivers compliant with ODBC 3.0 and later, truncated input parameters should result in a SQL_ERROR with SQLState 22001. However, the ODBC 2.5 specification requires that such cases result in SQL_SUCCESS_WITH_INFO with SQLState 01004 instead. Because the Microsoft Oracle driver is ODBC 2.5-compliant, this behavior is by design.

The following sample code reproduces this behavior:
   char   szStmt[] = "Select name, state from customer where state = ?";

   SQLRETURN  nResult;
   SWORD      nNumParams = 0;
   SQLINTEGER strLen = SQL_NTS;

   char       szState[80] = "CAL";  // Anything over 2 characters will do.

   nResult = SQLPrepare( hstmt, szStmt, SQL_NTS );
   nResult = SQLNumParams( hstmt, &nNumParams );
   nResult = SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, 
                               SQL_C_CHAR, SQL_CHAR,
                               2, 0, szState, sizeof(szState), &strLen );
   nResult = SQLFreeStmt( hstmt, SQL_CLOSE );
   nResult = SQLExecute( hstmt );
				

↑ Back to the top


Keywords: KB306006, kboracle, kbinfo, kbdriver, kbdatabase

↑ Back to the top

Article Info
Article ID : 306006
Revision : 3
Created on : 5/12/2003
Published on : 5/12/2003
Exists online : False
Views : 481