Bug #17068 Updated: MSSQL fails to open a SP using a cursor on query that contains an expression

From: Date: Fri, 19 Jul 2002 01:45:28 +0000
Subject: Bug #17068 Updated: MSSQL fails to open a SP using a cursor on query that contains an expression
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14577@lists.php.net to get a copy of this message
ID: 17068 Updated by: hujbanan@yahoo.com Reported By: jasonh@trurocollege.ac.uk Status: Feedback Bug Type: MSSQL related Operating System: WinNT 5.0 PHP Version: 4.2.0 New Comment: I have the same problem. I am using PHP statement mssql_query( "EXEC db_sequence 1, 2, 3, 1" ) {query B} to call stored procedure on MSSQL 2000 server, which produces output using cursor. Different is (against Jasons prob), that I use global cursor defined using mssql_query( "DECLARE rowset CURSOR GLOBAL SCROLL FOR $query" ) {query A} because I need dynamically choose executed query. Statement {A} creates global cursor which is fetched and dropped in SP db_sequence {B}. When I uses as $query SQL command 'SELECT id FROM store', it works fine. But if I use something like 'SELECT id+1 AS col FROM store', PHP crashes. Both sequences of SQL queries run without problems in SQL Query Analyzer (SQL 2k). I found this problem on PHP version 4.2.0 for win32. I try latest version of PHP from http://snaps.php.net/win32/ (both, stable v4.2.2-dev and unstable v4.3.0-dev) but problem persists. I'm using Apache 1.3.20/PHP 4.2.0 on Win2k advanced server. Can you tell me, what is wrong? Previous Comments: ------------------------------------------------------------------------ [2002-05-07 05:35:59] derick@php.net Cursors are broken in 4.2.0, it is fixed in 4.2.1-dev. To test yourself can a stable snapshot from snaps.php.net/win32, or wait for 4.2.1 which will be released next week. Derick ------------------------------------------------------------------------ [2002-05-07 05:32:22] jasonh@trurocollege.ac.uk The MSSQL extension fails to even open (using mssql_query) a query on a stored procedure that uses a cursor on a query containing an expression. The following SP works fine in Query Analyser (MSSQL7) but will not get past the mssql_query line in PHP. The occurrence of the expression "id + 1" is, bizarrely, the apparent cause of the problem. Changing this to just "id" makes it all work from PHP. ------------ CREATE PROCEDURE TestCursor AS --This makes no difference: -- set nocount on declare c scroll cursor for select id + 1 as newid from table open c fetch next from c while (@@fetch_status = 0) fetch next from c close c deallocate c -- set nocount off ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17068&edit=1

« previous php.bugs (#14577) next »