Detailed description of the oracle Stored Procedure instance accessed by php, And the oracle Stored Procedure

Source: Internet
Author: User

Detailed description of the oracle Stored Procedure instance accessed by php, And the oracle Stored Procedure

Php access to oracle Stored Procedure instances

For example, my local Oracle database has a package with a stored procedure:

Create or replace package PKG_TRANS_REL is -- Author: test -- Created: -- Purpose: test -- Public type declarations PKG_NAME varchar2 (20): = 'pkg _ TRANS_REL '; -- stored procedure, 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 and the stored procedure is pro_GC_withdraw. This stored procedure has four parameters: two input parameters and two output parameters.

Example of calling through 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::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);      return false;    }    ...

The third bindParam parameter defaults to PDO: PARAM_STR. If it is of another type, specify

The input parameter value is relatively simple, and the output parameter is slightly more complex. Specify the length..

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

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.