php 访问oracle 存储过程实例详解
比如我的本地Oracle数据库有一个package,里面有一个存储过程:
createorreplacepackage PKG_TRANS_RELis -- Author : test -- Created : -- Purpose : test -- Public type declarations PKG_NAME varchar2(20) :="PKG_TRANS_REL"; --存储过程,测试用 procedurepro_GC_withdraw(in_merch_no invarchar2, in_withdraw_amtinnumber, out_result outnumber, out_errmsg outvarchar2); endPKG_TRANS_REL;包名是PKG_TRANS_REL,存储过程是pro_GC_withdraw,这个存储过程有四个参数,两个入参,两个出参。
在PHP中通过pdo调用示例:
$this->_pdo =newPDO(PDO_DB_DNS, PDO_DB_USER, PDO_DB_PASSWORD); $call="CALL PKG_TRANS_REL.pro_GC_withdraw(?,?,?,?)"; try{ $stmt=$this->_pdo->prepare($call); $stmt->bindParam(1,$merch_no); $stmt->bindParam(2,$amount, PDO::PARAM_INT); $stmt->bindParam(3,$result, PDO::PARAM_INT, 4); $stmt->bindParam(4,$error_msg, PDO::PARAM_STR, 64); $stmt->execute(); }catch(PDOException$e) { $msg="SQL:".$e->getMessage(); $msg= iconv("GBK","UTF-8",$msg); user_dump("SQL:".$msg); returnfalse; } ...bindParam第三个参数默认是PDO::PARAM_STR,如果是其它类型就要指明
入参传值比较简单,出参稍微复杂些,要指明长度。
[php访问oracle存储过程]php访问oracle存储过程实例详解
http://m.bbyears.com/shujuku/118410.html
推荐访问: