PHP函数 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
<?php  
function getdaysandweeks(){ 
$dbh = new DB_Oracle ( );//这个我用了自己写的类了. $sql = "BEGIN getdaysandweeks(:day,:week); END;"; $stmt = $dbh->prepare ( $sql );//这个也是, oci_define_by_name($stmt,"day",$days_in_week); 
oci_define_by_name($stmt,"week",$weeks_in_month); $stmt->execute ();//这个也是 echo $days_in_week; 
echo $weeks_in_month; 

?> 
<P> <? getdaysandweeks()?> </P> 存储过程 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
create or replace procedure getdaysandweeks( v_day out varchar2,v_week out varchar2) is 
begin 
  select to_char(sysdate,'DD'),to_char(sysdate,'D')  into v_week,v_day from dual; 
end getdaysandweeks;//这个应该没问题,我在PL/SQL developer中TEST成功了. 

解决方案 »

  1.   

    Warning: oci_define_by_name() expects parameter 1 to be resource, object given in F:\zend\opc\estimate\dateindex.php on line 15 Warning: oci_define_by_name() expects parameter 1 to be resource, object given in F:\zend\opc\estimate\dateindex.php on line 16 Warning: oci_execute() [function.oci-execute]: ORA-01008: not all variables bound in F:\zend\opc\opc-sys\common\oracle.php on line 223 Fatal error: Execute failedBEGIN getdaysandweeks(:day,:week); END;at0Array ( [0] => Array ( [file] => F:\zend\opc\opc-sys\common\oracle.php [line] => 224 [function] => error [class] => DB_OracleStatement [type] => -> [args] => Array ( [0] => Execute failed ) ) [1] => Array ( [file] => F:\zend\opc\estimate\dateindex.php [line] => 17 [function] => execute [class] => DB_OracleStatement [type] => -> [args] => Array ( ) ) [2] => Array ( [file] => F:\zend\opc\estimate\dateindex.php [line] => 22 [function] => getdaysandweeks [args] => Array ( ) ) ) in F:\zend\opc\opc-sys\common\oracle.php on line 267 
      

  2.   

    还真有人遇到这种问题。
    在存储过程当中,绑定output变量,应该使用bindbypos/bindbyname。
    这是唯一的一种例外。估计常用OCI的人可能会遇到。常规sql查询,变量绑定,bindby*绑定输入,defineby*绑定输出。
    存储过程则不同。