PHP access to Oracle stored procedure examples

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.