Bug #69526 [Asn]: odbc_execute can't be executed twice on some drivers
| From: | ab@php.net | Date: | Wed, 24 Feb 2016 07:58:45 +0000 |
| Subject: | Bug #69526 [Asn]: odbc_execute can't be executed twice on some drivers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-199440@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69526&edit=1
ID: 69526
Updated by: ab@php.net
Reported by: einavitamar at gmail dot com
Summary: odbc_execute can't be executed twice on some drivers
Status: Assigned
Type: Bug
Package: ODBC related
Operating System: Windows
PHP Version: 5.6.8
Assigned To: ab
Block user comment: N
Private report: N
New Comment:
Now, it looks like same issue in regard to bug #47803. I think your patch is reasonable. Testing
this currently.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2015-05-04 10:31:13] einavitamar at gmail dot com
I supplied a test script when I submitted the ticket.
The TeraData driver is freely downloadable from teradata web site
https://downloads.teradata.com/download/connectivity/odbc-driver/windows
You can also download the server as a virtual machine:
http://www.teradata.com/Resources/Brochures/Teradata-Virtual-Machine-Edition/
For data that matches the test script, simply create a table called einav with one column called
"a":
CREATE TABLE einav (a varchar);
------------------------------------------------------------------------
[2015-04-28 13:46:21] ab@php.net
Could you supply some test data please. Some driver bins probably, as well, if they aren't
freely downloadable.
Thanks.
------------------------------------------------------------------------
[2015-04-24 16:43:00] einavitamar at gmail dot com
Description:
------------
After odbc_prepare, when executing odbc_execute more than once, it fails starting the second time.
It happens only in drivers that does not allow SQLDescribeParam to be called on a statement after
its execution.
By looking at the php odbc code, the reason is that SQLDescribeParam is called in odbc_execute
instead of in odbc_prepare.
It should be called only once per bound parameter, and it does not depend on the parameter value
itself, so it should be called in odbc_prepare.
This failure happens when using odbc both in TeraData and in Vertica.
This failure happens only if there is parameter binding (for statements without variables it does
not happen).
The test script is for TeraData driver under windows.
Test script:
---------------
$conn =
odbc_connect("driver={Teradata};DBCName=127.0.0.1;PortNumber=1025;DATABASE=dbname;",'user',
'pwd');
$sql = "SELECT * FROM einav where a >= ?;";
$stmt = odbc_prepare($conn,$sql);
$params = array("abc");
odbc_execute($stmt,$params);
odbc_result_all($stmt);
odbc_execute($stmt,$params);
odbc_result_all($stmt);
Expected result:
----------------
Expected result:
<table><tr><th>a</th></tr>
<tr><td>abc</td></tr>
<tr><td>cde</td></tr>
</table>
<table><tr><th>a</th></tr>
<tr><td>abc</td></tr>
<tr><td>cde</td></tr>
</table>
Actual result:
--------------
<table><tr><th>a</th></tr>
<tr><td>abc</td></tr>
<tr><td>cde</td></tr>
</table>
PHP Warning: odbc_execute(): SQL error: [Teradata][ODBC Teradata Driver] Functi
on Sequence Error, SQL state S1010 in SQLDescribeParameter in C:\Users\einav.000
\b.php on line 37
<h2>No rows found</h2>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69526&edit=1