【问题标题】:How to execute a stored procedure using OCI8 in PHP [closed]如何在 PHP 中使用 OCI8 执行存储过程 [关闭]
【发布时间】:2013-04-08 21:20:10
【问题描述】:

谁能帮助我如何通过php调用oracle中的存储过程? 我有存储过程的示例

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

上述名为view_instituion 的存储过程用于显示表机构上的所有记录。有人可以教我在 php.ini 中调用上述存储过程吗?我刚开始玩存储过程

谢谢

【问题讨论】:

标签: php oracle stored-procedures oci8


【解决方案1】:

如果您使用 PDO 引擎

/* 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);

如果您使用 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);

【讨论】:

  • 哦..我用的是oci..是一样的吗?
  • 这是我连接到 oracle db 的示例..
  • 为OCI做了一个例子。好久没用了,不过我觉得这样就对了。
  • @user2234937 oci 是 oracle 特定的,PDO 是针对多种数据库类型的
  • 谢谢.. 对于我的情况,:parameter 是什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-08
  • 2016-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多