Bug #76732 [Com]: Unable to fetch text and varchar(max) when procedure returns more result sets
| From: | honza dot hink at gmail dot com | Date: | Sat, 24 Aug 2019 08:04:19 +0000 |
| Subject: | Bug #76732 [Com]: Unable to fetch text and varchar(max) when procedure returns more result sets | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222387@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76732&edit=1
ID: 76732
Comment by: honza dot hink at gmail dot com
Reported by: honza dot hink at gmail dot com
Summary: Unable to fetch text and varchar(max) when procedure
returns more result sets
Status: Open
Type: Bug
Package: ODBC related
Operating System: Windows 10
PHP Version: 7.2.8
Block user comment: N
Private report: N
New Comment:
This case is bewhiskered, nobody concerns. Build a headstone.
Previous Comments:
------------------------------------------------------------------------
[2018-08-12 13:22:08] honza dot hink at gmail dot com
Description:
------------
odbc_fetch_array() reports error: SQL error: [Microsoft][SQL Server Native Client 11.0]Invalid
Descriptor Index, SQL state S1002 in SQLGetData in ...
It is related to Bug #73725, that has been partially solved, but it remains by this circumstances:
This error occurs on reading result with two conditions at the same time.
First condition:
- SQL syntax contains more than one command (select or execute)
OR
- SQL command contains anything extra, f.e. "set nocount on execute ..."
OR
- SQL command contains any comment, f.e. "/* any comment */ select ..."
OR
- SQL command calls a procedure that returns more than one result
Second condition:
- one of sql results contains column type text or not empty varchar(max)
If one condition is not true, then it works OK.
There are differences between drivers "SQL Server" and "SQL Server Native
Client". One doesn't like text type if it is not the last column, another driver
doesn't like not empty varchar(max).
My example contains both features, so it gives an error regardless used driver.
Test script:
---------------
<?php
header("Content-Type: text/html; charset=utf-8");
$con=odbc_connect("Local64bit","any_user","his_pwd");
$res1=odbc_do($con,"create procedure #p as
select convert(text,'text 1') converted_to_text, 1 i, convert(varchar(max),'text
1') converted_to_varchar_max
select convert(text,'text 2') converted_to_text, 1 i, convert(varchar(max),'text
2') converted_to_varchar_max
");
$res2=odbc_do($con,"execute #p");
while($r=odbc_fetch_array($res2))
print_r($r);
?>
Expected result:
----------------
Array
(
[converted_to_text] => text 1
[i] => 1
[converted_to_varchar_max] => text 1
)
Actual result:
--------------
<br />
<b>Warning</b>: odbc_fetch_array(): SQL error: [Microsoft][SQL Server Native Client
11.0]Invalid Descriptor Index, SQL state S1002 in SQLGetData in
<b>F:\EclipseWorkspaces\Ramses\www\pokus.php</b> on line <b>9</b><br
/>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76732&edit=1