PHP access to Oracle stored procedure examples
For example, my local Oracle database has a package with a stored procedure:
Create or Replace package Pkg_trans_rel are --author:test--Created:--purpose:test --Public type Declarat Ions Pkg_name varchar2 (): = ' Pkg_trans_rel '; --stored procedure, test with procedure Pro_gc_withdraw (in_merch_no in varchar2, In_withdraw_amt in number , out_result Out number , out_errmsg out varchar2); end Pkg_trans_rel;
The package name is Pkg_trans_rel, the stored procedure is pro_gc_withdraw, the stored procedure has four parameters, two entry parameters, two out of the parameters.
To invoke the sample via PDO in PHP:
$this->_pdo = new PDO (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::P aram_int); $stmt->bindparam (3, $result, PDO::P aram_int, 4); $stmt->bindparam (4, $error _msg, PDO::P aram_str,); $stmt->execute (); } catch (pdoexception $e) { $msg = ' SQL: '. $e->getmessage (); $msg = Iconv (' GBK ', ' UTF-8 ', $msg); User_dump (' SQL: '. $msg); return false; } ...
Bindparam the third parameter, by default, is PDO::P aram_str, if it is another type, specify
The value of the entry parameter is simple, the parameter is slightly more complicated, to indicate the length.