Question

Can someone help me on how to call the stored procedure in oracle by php? I have the sample of stored procedure

CREATE OR REPLACE PROCEDURE view_institution(
       c_dbuser OUT SYS_REFCURSOR)
IS
BEGIN
  OPEN c_dbuser FOR
  SELECT * FROM institution;
END;

the above stored procedure named view_instituion used to display all record on table institution. Can someone teach me to call the above stored procedure in php. Im new on playing with stored procedure

thanks

Était-ce utile?

La solution

If you use the PDO engine

/* Define output */
$output = "";    

/* The call */
$stmt= $pdo->prepare("CALL view_institution(?)");

/* Binding Parameters */
$stmt->bindParam($parameter1, $output);
 
/* Execture Query */
$stmt->execute();

/* Get output on the screeen */
print_r($output, true);

If you use oci

/* The call */
$sql = "CALL view_institution(:parameter)";

/* Parse connection and sql */
$stmt= oci_parse($conn, $sql);
 
/* Binding Parameters */
oci_bind_by_name($stmt, ':parameter', $yourparameter) ;

/* Execute */
$res = oci_execute($stmt);

/* Get the output on the screen */
print_r($res, true);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top