duansha6410 2010-07-09 10:16
浏览 37
已采纳

PHP的Oracle存储过程调用

Here the code:

<?php
include_once 'config.php';

// Connect to database
$conn = oci_connect($dbuser, $dbpasswd, $dbhost."/".$dbname);
if (!$conn) {
    exit ("Connection failed.");
}

$id   = isset($_GET['id']) ? (int)$_GET['id'] : false;
$type = isset($_GET['type']) ? strtoupper($_GET['type']) : "BLOG";

$stmt = oci_parse($conn, 
    "begin 
    PKG_LIKE.get_LikeId(
    :I_N_Id,
    :I_S_Type,
    :O_N_grade,
    :O_N_exitFlag,
    :O_S_exitMsg);
    end;");

oci_bind_by_name($stmt, "I_N_Id", $id);
oci_bind_by_name($stmt, "I_S_Type", $type);
oci_bind_by_name($stmt, "O_N_grade", $total);
oci_bind_by_name($stmt, "O_N_exitFlag", $flag);
oci_bind_by_name($stmt, "O_S_exitMsg", $message);

if (!oci_execute($stmt)) {
    exit("Procedure Failed.");
}

if ($message == 'OK') {
    $response = array('likeit' => $total);
    $toReturn = "var response=".json_encode($response)."; showTotalLikeit(response);";
} else {
    $response = array('likeit' => 'NaN', 'exitFlag' => $flag, 'exitMsg' => $message);
    $toReturn = "var response=".json_encode($response)."; showTotalLikeit(response);";
}

print $toReturn;

Result is "Procedure Failed". Where am I failing? I've just used a stored procedure call (but with cursors as output) till now and all was fine.

Launching the SP on Oracle works fine so it's a php problem.

  • 写回答

3条回答 默认 最新

  • drs3925 2010-07-10 08:11
    关注

    Magically it works while i was debugging using some echo to print the content of some variables.

    I'm sure i've to kill a SysAdmin for these days wasted.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable