Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.2

Bug #58 ODBC result not freed for UPDATE and INSERT
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)    
Subscription  


 [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 ;)

Comments

 [2004-02-04 08:03 UTC] danielc
This could also be solved by adding a call to DB_result::free() in your script, for example: $Result->free(); Placing a free call inside simpleQuery() would interfere with situations where users want to do things with the output from modify queries.