好的,我是 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);