当前位置:Gxlcms > PHP教程 > php传值给ORACLE存储过程,该如何处理

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

时间:2021-07-01 10:21:17 帮助过:14人阅读

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
  1. $user = "scott"; //数据库用户名
  2. $password = "tiger"; //密码
  3. $conn_str = "tnsname"; //连接串(cstr : Connection_STRing)
  4. $remote = true //是否远程连接
  5. if ($remote) {
  6. $conn = OCILogon($user, $password, $conn_str);
  7. }
  8. else {
  9. $conn = OCILogon($user, $password);
  10. }
  11. $a='S_a';
  12. $b='S_b';
  13. $c='S_c';
  14. $d='S_d';
  15. $e='S_e';
  16. $sql_sp = "BEGIN PROC_TEST(:a, :b,:c,:d,:e); END;";
  17. //Parse
  18. $stmt = OCIParse($conn, $sql_sp);
  19. //执行绑定
  20. OCIBindByName($stmt, ":a", $a, 30);
  21. OCIBindByName($stmt, ":b", $b, 30);
  22. OCIBindByName($stmt, ":c", $c, 30);
  23. OCIBindByName($stmt, ":d", $d, 30);
  24. OCIBindByName($stmt, ":e", $e, 30);
  25. OCIExecute($stmt);<br><b>我的异常网推荐解决方案:</b>oracle存储过程,http://www.myexception.cn/oracle-develop/177537.html

人气教程排行