Skip to Content.
Sympa Menu

freetds - Re: PHP crash on 2nd Select

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Bob Kline <bkline AT rksystems.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: PHP crash on 2nd Select
  • Date: Fri, 13 Jul 2001 18:49:14 -0400 (EDT)


On Fri, 13 Jul 2001, Brian Bruns wrote:

> In the native APIs (dblib/ctlib) the appropriate behaviour in a case
> like this is to generate an error (though obviously core dumping is
> not the right response ;-) that is a bug). Anyway the client issues
> an error like 'Attempt to initiate new query with results pending'.
>
> I'm assuming here that odbc isn't suppose to act this way. Can
> anyone provide pointer to this from the ODBC documentation? But in
> any event, fixing this is simple.

This is a state transition error, for which the driver is supposed to
return SQLSTATE 24000 (Invalid cursor state).

See the "State Transitions" section of chapter 4: "If an application
calls a function out of order, the function returns a state transition
error."[1] See also Chapter 10: "Until the application closes the
cursor, the statement on which the cursor is opened cannot be used for
most other operations, such as executing another SQL statement."[2]

When the application does close the cursor (SQLCloseCursor(hstmt)), the
driver is responsible for doing whatever is necessary (e.g., discarding
any unfetched results) to enable a new SQL statement to be executed
using the statement handle.

Also, take a look at the state transition tables in the appendices.[3]
These tables specify the exact error return for each illegal state
transition.

[1]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcstate_transitions.asp
[2]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcclosing_the_cursor.asp
[3]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcodbc_state_transition_tables.asp

--
Bob Kline
mailto:bkline AT rksystems.com
http://www.rksystems.com






Archive powered by MHonArc 2.6.24.

Top of Page