To invoke the previously created PL/SQL procedure, use the SQL CALL statement like:
<?php
$c = oci_connect('hr', 'hrpwd', '//localhost/XE');
$s = oci_parse($c, "call myproc('Chris', 123)");
oci_execute($s);
?>
//The call command is actually a SQL command and does not have a trailing semi-colon.
//You can also use an anonymous block. In the next example, the block contains a single
//procedure call, but you could include any number of other PL/SQL statements:
<?php
$c = oci_connect('hr', 'hrpwd', '//localhost/XE');
$s = oci_parse($c, "begin myproc('Alison', 456); end;");
oci_execute($s);
?>
//Calling a PL/SQL function needs a bind variable to hold the return value. Using the function
//myfunc() created above:
<?php
$c = oci_connect('hr', 'hrpwd', '//localhost/XE');
$s = oci_parse($c, "begin :ret := mypack.myfunc(123); end;");
oci_bind_by_name($s, ':ret', $r, 20);
oci_execute($s);
echo "Name is: ".$r;
?>
<pre>
The output is:
Name is: Chris
This example also shows how to call a function inside a package using the syntax
packagename.procedurename().
</pre>
|