php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #13195 Support for OUT parameters from Stored Procedures in ODBC wrapper
Submitted: 2001-09-07 11:23 UTC Modified: 2005-09-26 16:53 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: martinrosenauer at hotmail dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.0.6 OS: Linux
Private report: No CVE-ID: None
 [2001-09-07 11:23 UTC] martinrosenauer at hotmail dot com
As of now the odbc-wrapper, for example used with DB2 databases, support calling stored procedures. It supports IN parameters used with stored procedures as well, but not OUT parameters (meaning you can get parameters returned to PHP when calling a stored procedure). 

This is for example possible when using Perl and DBI (against DB2). The method there that enables it is called Bind (where you bind a var to an out parameter). Unfortunately this method is not available as odbc_bind. 

If this is by any chance possible I'd be more than happy!

I had a brief dialog with Frank Kromann (frank@frontbase.com), who was involved with the ODBC wrapper implementation and he confirmed that a binding or OUT parameter support was already there.

Best regards and thanks a mill,

Martin Jacobsen, Denmark

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-21 10:51 UTC] nicolas dot karageuzian at clubmed dot com
Hi, we tried the following example :
<?php
  $proc_qry = "CALL CM.CLIBROS(? , ? , ?)";
  $dbconn = dbconnect();
  $proc_stmt = odbc_prepare($dbconn,$proc_qry);
  $codFon = 0;
  $codPYC = "010";
  $codRet = "";
  $values = array ($codFon,$codPYC,$codRet);
  $result = odbc_execute($proc_stmt,$values) ;
  while(odbc_fetch_row($result)){
    for($i=1;$i<=odbc_num_fields($result);$i++){
       echo "colonne ".i." : ".odbc_result($result,$i);
    } //for
  } //while

the third parameter of CLIBROS stored procedure is an output parameter. PHP reported this error :
 [error] PHP Warning:  odbc_execute(): SQL error: [IBM][CLI Driver] CLI0005W  Option value changed. SQLSTATE=01S02, SQL state 01S02 in SQLExecute in testPRS.php on line 31

we didn't find how to register an output parameter for the statement.
 [2005-09-26 16:53 UTC] dbs@php.net
There are now a number of native drivers that explicitly support OUT parameters from stored procedures; for your particular example, the ibm_db2 extension in PECL (http://pecl.php.net/ibm_db2, with docs available at http://php.net/ibm_db2) supports OUT parameters for DB2, Cloudscape, and Apache Derby databases beginning with PHP 4.3.11 and higher (including PHP 5.0/5.1).

Apparently the challenge with making this support available in the Unified ODBC extension is that the specific requirements vary so much by database that it is next to impossible to extend support for every feature for every database in the Unified ODBC extension -- therefore, the mssql extension supports OUT parms for MS SQL Server, the OCI8 extension supports OUT parms for Oracle, the ibm_db2 extension supports OUT parms for DB2, etc. 

Note that the PDO_ODBC driver for the PHP Data Objects (PDO) extension does support OUT parms for DB2 natively, as well as other databases that offer ODBC drivers. PDO requires PHP 5.0 and above.

So I'm closing this as "Won't fix", noting that there are better alternatives than the Unified ODBC extension for this functionality.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 21:01:26 2024 UTC