php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17068 MSSQL fails to open a SP using a cursor on query that contains an expression
Submitted: 2002-05-07 05:32 UTC Modified: 2002-07-19 01:00 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: jasonh at trurocollege dot ac dot uk Assigned:
Status: No Feedback Package: MSSQL related
PHP Version: 4.2.0 OS: WinNT 5.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jasonh at trurocollege dot ac dot uk
New email:
PHP Version: OS:

 

 [2002-05-07 05:32 UTC] jasonh at trurocollege dot ac dot 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-07 05:35 UTC] 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-07-18 21:45 UTC] hujbanan at yahoo dot com
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?
 [2002-07-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC