2009-10-26 41 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'];  
}