PHP calls Oracle stored procedure with out parameters

Source: Internet
Author: User
Tags stmt

Enter the parameter
$in 1 = ' 2017-01-01 '; Must fill in
$in 2 = ' 2017-08-01 '; Must fill in
$in 3 = "; Optional fill

$tns = ' (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 0.0.0.0) (PORT = 1521)) (Connect_data = (service_name = dbname ) (SID = dbname)) ';
$conn = oci_connect (' user ', ' password ', $tns, ' UTF8 ' );   
if (! $conn) {
$e = Oci_error ();
Trigger_error (Htmlentities ($e [' message ']), e_user_error);
}
$curs = Oci_new_cursor ($conn);
$stmt = Oci_parse ($conn, "Begin package_name. Procedure_name (: In1,:in2,:in3 ,: OUT1); end; ");
Oci_bind_by_name ($stmt, ': IN1 ', $in 1);
Oci_bind_by_name ($stmt, ': IN2 ', $in 2);
Oci_bind_by_name ($stmt, ': IN3 ', $in 2);
Oci_bind_by_name ($stmt, ": OUT1", $curs ,-1, Sqlt_rset );
Oci_execute ($stmt);
Oci_execute ($curs, oci_default);

while (($row = Oci_fetch_row ($curs)) = = False) {
Var_dump ($row);
}
Oci_free_statement ($stmt);
Oci_free_statement ($curs);
Oci_close ($conn);

The red part needs attention.

1,' UTF8 ' note the character set, if there is Chinese in the argument, there is no specified character set, may affect the result.

2,: IN3 Although the argument is an optional parameter, the call is also an empty string, but must be called with this parameter, otherwise the desired result is not obtained.

3,$curs, sqlt_rset Note the type of the argument, what type of stored procedure is used to receive the corresponding class type.

PHP calls Oracle stored procedure with out parameters

Related Article

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.