PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #58

ODBC result not freed for UPDATE and INSERT

Details

Submitted2003-10-03 09:41 UTC
Fromecarpenter at itex dot co dot za
Assigneddanielc
StatusBogus
PackageDB
PHP Version4.3.1
OSLinux
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 ;)