Bug #72503 [Nab]: [ODBC Cursor Library] Result set was not generated by a SELECT statement, SQL s

From: Date: Wed, 06 Jul 2016 10:30:39 +0000
Subject: Bug #72503 [Nab]: [ODBC Cursor Library] Result set was not generated by a SELECT statement, SQL s
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202091@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72503&edit=1 ID: 72503 User updated by: jgeert1 at its dot jnj dot com Reported by: jgeert1 at its dot jnj dot com Summary: [ODBC Cursor Library] Result set was not generated by a SELECT statement, SQL s Status: Not a bug Type: Bug Package: ODBC related Operating System: Windows Server 2008 R2 PHP Version: 5.6.23 Block user comment: N Private report: N New Comment: I do not agree on that one: Please read: https://technet.microsoft.com/en-us/library/ms130807(v=sql.110).aspx SQL_CURSOR_FORWARD_ONLY is the default setting for the SQL Server Native Client ODBC driver. Previous Comments: ------------------------------------------------------------------------ [2016-07-06 10:00:31] ab@php.net Typo - "if the row set size > 1". Thanks. ------------------------------------------------------------------------ [2016-07-06 09:55:09] ab@php.net Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Thanks for the additional info. In this case, it is an inappropriate configuration. Forward-only cursors shouldn't be used, if the rowset size >= 1. It is documented here https://msdn.microsoft.com/en-us/library/ms715441(v=vs.85).aspx Thanks. ------------------------------------------------------------------------ [2016-07-04 13:47:46] jgeert1 at its dot jnj dot com Meanwhile after doing some additional testing, I noticed that I only have this error when a table has columns defined as "ntext" or "varchar(max)" or "nvarchar(max)" fields. If I remove these columns from my sql statement, the query runs fine again. When I create a dummy table like this: CREATE TABLE [dbo].[jg_test]( [id] [int] IDENTITY(1,1) NOT NULL, [test1] [int] NULL, [test2] [varchar](50) NULL, [test3] [varchar](max) NULL, [test4] [nvarchar](max) NULL, [test5] [int] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] just add some dummy data to it (in my case the varchar fields only contain "test"). use this code to access it: $user = "username"; $pwd = "password"; $dsn = "Driver={SQL Server Native Client 11.0};Server=myserver;Database=mydb;MARS_Connection=Yes;"; ini_set ('odbc.default_cursortype',SQL_CURSOR_FORWARD_ONLY); $dbhandle = odbc_connect($dsn,$user,$pwd,SQL_CUR_USE_DRIVER); $result = odbc_exec($dbhandle, "select * from dbo.jg_test"); while( $row = odbc_fetch_array($result)) { var_dump($row); } odbc_free_result($dbhandle); odbc_close($dbhandle); This will result in the error message: Warning: odbc_fetch_array(): SQL error: [Microsoft][SQL Server Native Client 11.0]Invalid Descriptor Index, SQL state S1002 in SQLGetData I know it's a different error message then the one posted before, but I'm sure that these are related to each other. ------------------------------------------------------------------------ [2016-07-01 11:22:28] ab@php.net Please provide the full reproduce way with table creaton, data, and all the necessary things. Thanks. ------------------------------------------------------------------------ [2016-06-27 12:11:31] jgeert1 at its dot jnj dot com ODBC Traces can be found here: https://gist.github.com/anonymous/f91784cedbe6a6eb58e88b814deef5c6 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=72503 -- Edit this bug report at https://bugs.php.net/bug.php?id=72503&edit=1

« previous php.bugs (#202091) next »