Home > Backend Development > PHP Tutorial > php传值给ORACLE存储过程,该如何处理

php传值给ORACLE存储过程,该如何处理

WBOY
Release: 2016-06-13 12:50:46
Original
811 people have browsed it

php传值给ORACLE存储过程
本人的客户在ORACLE服务器上写了一个存储过程,他告诉了我存储过程名称(pro)、数据库名称、TNSNAME、访问密码、数据表名称、及5个字段名称。

现在我要在我开发的PHP程序上远程调用这个ORACLE存储过程,目的很简单,就是把5个PHP变量值传给存储过程(pro)中的5个字段,分别是S_a 、S_b 、S_c 、S_d 、S_e

另外存储过程(pro)在接收了上面5个值之后,会返回一个结果值,字段名为S_F

请问具体代码要怎样写?

我把我所有的分都付给能解决我问题的高手!!

------解决方案--------------------

PHP code

$user = "scott";                //数据库用户名
$password = "tiger";            //密码
$conn_str = "tnsname";          //连接串(cstr : Connection_STRing)
$remote = true                  //是否远程连接
if ($remote) {
  $conn = OCILogon($user, $password, $conn_str);
}
else {
  $conn = OCILogon($user, $password);
}
$a='S_a';
$b='S_b';
$c='S_c';
$d='S_d';
$e='S_e';
$sql_sp = "BEGIN PROC_TEST(:a, :b,:c,:d,:e); END;";

//Parse
$stmt = OCIParse($conn, $sql_sp);

//执行绑定
OCIBindByName($stmt, ":a", $a, 30);          
OCIBindByName($stmt, ":b", $b, 30);
OCIBindByName($stmt, ":c", $c, 30);
OCIBindByName($stmt, ":d", $d, 30);
OCIBindByName($stmt, ":e", $e, 30);
OCIExecute($stmt);<br><b>我的异常网推荐解决方案:</b>oracle存储过程,http://www.myexception.cn/oracle-develop/177537.html <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template