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