【问题标题】:PHP Oracle Ref CursorPHP Oracle 参考光标
【发布时间】:2010-12-10 04:46:00
【问题描述】:

好的,我是 PHP/Oracle 连接器的新手。我想要做的是调用一个简单的存储过程,它接受一个 id 号并返回一个值。如果有匹配,它可以正常工作,但我一生都无法弄清楚如果没有匹配,如何添加条件逻辑。基本上,如果有匹配,设置 $strategy 到它,如果没有匹配,设置 $strategy 为 NULL。

$sql = 'BEGIN STOREDPROCEDURENAME(:v_id_number, :entries); END;';

$stmt = oci_parse($conn, $sql);

oci_bind_by_name($stmt,':v_id_number',$id_number,32);

// Create a new cursor resource
$entries = oci_new_cursor($conn);

// Bind the cursor resource to the Oracle argument
oci_bind_by_name($stmt,":entries",$entries,-1,OCI_B_CURSOR);

// Execute the statement
oci_execute($stmt);

// Execute the cursor
oci_execute($entries);

while ($entry = oci_fetch_array($entries)) {
        $strategy = $entry['STRATEGY'];
    }

oci_close($conn);

【问题讨论】:

    标签: php oracle stored-procedures conditional while-loop


    【解决方案1】:

    怎么样

    $strategy = null;
    if ($entry = oci_fetch_array($entries)) {
         $strategy = $entry['STRATEGY'];       
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多