Home » Database » DB » Bug #58
ODBC result not freed for UPDATE and INSERT
Details
| Submitted | 2003-10-03 09:41 UTC |
|---|---|
| From | ecarpenter at itex dot co dot za |
| Assigned | danielc |
| Status | Bogus |
| Package | DB |
| PHP Version | 4.3.1 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2003-10-03 09:41 UTC] ecarpenter at itex dot co dot za
Description:
------------
No records set are returned from a stored procedure if an UPDATE or an INSERT query was done before calling the SP.
Database: Sybase ASA 8.0.2 (4289)
Connect type: ODBC
Reproduce code:
---------------
<?php
include "DB.php";
$DBase = DB::connect("odbc://dba:sql@tams");
$Result = $DBase->query("update <your.table.name> set test2='testing' where test1=1");
$Qry = $DBase->query("call TestSP()");
while ($Row = $Qry->fetchrow()) {
print_r($Row);
}
?>
CREATE PROCEDURE DBA."TestSP" ()
RESULT (Msg varchar(20))
BEGIN
DECLARE LOCAL TEMPORARY TABLE TempTable (
MSG varchar(20)
);
insert into TempTable values('testing this bug');
select MSG from TempTable;
END
Expected result:
----------------
1. The test table is updated
2. The stored procedure returns a 1 row result that should be displayed in the while loop.
Actual result:
--------------
1. The test table is updated
2. The stored procedure returns a 1 row result however the while loop is not entered.
This problem can be fixed by doing a odbc_free_result on the returning result of the UPDATE instruction.
The problem can be solved by added the following code to the start of the simpleQuery function in odbc.php
if ($this->manip_result) {
@odbc_free_result($this->manip_result);
$this->manip_result=0;
}//if
I do not know what I am breaking with the above code ;)