Edit report at https://bugs.php.net/bug.php?id=11&edit=1

 ID:                 11
 Comment by:         junxing dot lin at yahoo dot com
 Reported by:        walton at nordicdms dot com
 Summary:            odbc_exec() fails on successful query
 Status:             Closed
 Type:               Bug
 Package:            ODBC related
 Operating System:   WinNT 4.0
 PHP Version:        3.0 Latest CVS
 Block user comment: N
 Private report:     N

 New Comment:

http://www.chishairstraighteners.net     chi flat iron
http://www.chishairstraighteners.net     chi flat irons
http://www.chishairstraighteners.net     chi hair straightener
http://www.chishairstraighteners.net     chi hair straighteners


Previous Comments:
------------------------------------------------------------------------
[1998-01-27 07:49:38] ssb

This patch submitted and appears in functions/unified_odbc.c
version 1.26.


------------------------------------------------------------------------
[1998-01-26 18:58:26] walton at nordicdms dot com

[Reposted for entry into the nifty new bug database]

We've been calling stored procedures in MS-SQL thusly:

  $result = odbc_exec($conn,"exec sp_asp_dmsGetArtist 303");

That has worked up to and including 3.0b2a.  However in
more recent versions, including 3.0b4-dev, that code has 
produced:

  Warning:  Function SQLExecDirect in testodbc.php3 on line 22
  Warning:  SQL error: [Microsoft][ODBC SQL Server Driver]Cursor type 
            changed, SQL state 01S02 in testodbc.php3 on line 22

According to ODBC docs:

  SQLSTATE:  01S02
  Error:  Option value changed
  Description:  The driver did not support the specified
                value of the vParam argument and
                substituted a similar value. (Function
                returns SQL_SUCCESS_WITH_INFO.)

By comparing the 3.0b2a and 3.0b3-dev unified_odbc.c files,
we've located the probable cause of this error.  In
php3_uodbc_do() on line 763 (in 3.0b3-dev) we see:

  if(SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)
     != SQL_SUCCESS){

That function call appears to complete successfully.  Then,
on line 776 we see:

  if((rc = SQLExecDirect(result->stmt, query, SQL_NTS)) != SQL_SUCCESS){

It is this function that appears to generate the error.  My
guess is that our ODBC driver doesn't support SQL_CURSOR_DYNAMIC
and falls back to the default cursor type (which works fine
in 3.0b2a).  The query then completes successfully (according
to SQLTrace), and returns SQL_SUCCESS_WITH_INFO (according to
ODBC doc quote above).

Based on this information, I believe the fix is to replace 
line 776 with:

  rc = SQLExecDirect(result->stmt, query, SQL_NTS);
  if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=11&edit=1

Reply via email to