[unixODBC-support] SQLSTATE changes after SQLGetDiagRecW

Nick Gorham nick at lurcher.org
Wed Jul 31 19:52:22 BST 2013


On 31/07/13 18:52, Frank A. U. wrote:
> Hello,
> Please have a look at the following log.
>
> I call SQLSetEnvAttr() and it fails with the SQLSTATE error HY024.
>
> [ODBC][2718][1375292272.095758][SQLSetEnvAttr.c][189]
> 		Entry:
> 			Environment = 0x7fffec0009f0
> 			Attribute = SQL_ATTR_ODBC_VERSION
> 			Value = 0x7fffe7fafff0
> 			StrLen = 0
> [ODBC][2718][1375292272.095848][SQLSetEnvAttr.c][256]Error: HY024

Thats the state the driver manager gets which is a ODBC3 state.
>
> Then I'm starting to fetch the diagnostic messages.  I start by querying
> for the length of the message starting with record 1.
>
> (BTW: In case you are wondering I double the buffer size later to make
> sure even UTF-16 would fit).
>
> [ODBC][2718][1375292272.096185][SQLGetDiagRecW.c][385]
> 		Entry:
> 			Environment = 0x7fffec0009f0
> 			Rec Number = 1
> 			SQLState = (nil)
> 			Native = (nil)
> 			Message Text = (nil)
> 			Buffer Length = 0
> 			Text Len Ptr = 0x7fffe7faffe8
> [ODBC][2718][1375292272.096237][SQLGetDiagRecW.c][427]
> 		Exit:[SQL_SUCCESS_WITH_INFO]
> 			SQLState = (null)
> 			Native = NULLPTR
> 			Message Text = [NULLPTR]
>
> Next I fetch the actual message.  However the SQLSTATE suddenly changes
> to S1009.  If I interpret the standard correctly this must never happen

Thast because the driver manager belies the application is a ODBC 2 one, 
so it maps the ODBC 3 state to the equivalent ODBC 2 one.

-- 
Nick


More information about the unixODBC-support mailing list