ORCL_Stored_Func_php1
Intranet Link:

http://manas8x/BareBone_PHP/procedure_php1/procedure_php1.php

Create a function that will convert temp 0C to temp0F
Script :

create or replace
FUNCTION CTOF(i IN NUMBER)
RETURN NUMBER IS
t1 number(4,2);
BEGIN
dbms_output.put_line('Internal display');
dbms_output.put_line((i * 9/5) + 32);
t1:=((i*9/5)+32);
RETURN t1;
END ;
 

PHP


<?php
$conn = oci_connect('hr', 'Son', 'localhost/orcl.gateway.2wire.net');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
exit();
}
echo" HR/DB connected: digging Stored Function <br/>";
//
//$p1 = 29.25;
$stid = oci_parse($conn, "begin :bv:=CTOF(29.25); end;");
echo "uses oci_bind_name </br/>";
oci_bind_by_name($stid, ":bv", $p1, 6);
$result= oci_execute($stid);

echo "Conversion temp <sup>0</sup> C to <sup>0</sup>F <br/>";
echo "29.25<sup>0</sup>C =".$p1 ." <sup>0</sup>F<br/>";
oci_free_statement($stid);
oci_close($conn);

echo " db closed";

?>
 

Using sql*plus

DECLARE
C NUMBER(4,2):=0;
BEGIN
C :=CTOF(29.25);
dbms_output.put_line('CTOF returned : '|| C);
END;
 

Testing with SQL * Plus command line tool;

Testing with PHP /IIS /FastCGI : windows 7 ultimate

Runt time views"