2009-10-26 42 views
0

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

$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); 

回答

0

如何

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