/*common_exec_storeproc
Description: Execute a store procedure.
Input parameter:
$conn connection string of oracle.
$proc_name Name of the store procedure you want exec.
$in_count Count of input parameter for store procedure.
$out_count Count of output parameter for store procedure.
$in_arrays List of input parameter.
$out_array List of output parameter.
Return parameter:
$ret true: execute ok, false: execute fail.
sample:
$conn = connect_database("username","password","sid");//or $conn = connect_database("username","password","")
if ($conn)
{
$value_param = array("ipcatis",2 );
if (common_exec_storeproc($conn,"yourprocedurename",2,1,$value_param,$out_array))
echo "exec ok";
foreach($out_array as $key => $val)
{
echo $val."
";
};
}
else
echo "Not conected!";
if ($conn)
disconnect_database($conn);
*/
function common_exec_storeproc($conn,$proc_name,$in_count,$out_count,$in_arrays,&$out_array)
{
//echo $in_count."".$out_count."/
";
$sql = "begin "."$proc_name"."(";
for ($i = 0; $i < $in_count + $out_count; $i++)
{
$sql.= ":param$i";
if ($i < $in_count + $out_count - 1)
$sql.=",";
}
$sql.="); end;";
//echo $sql;
$stmt = OCIParse($conn,$sql);
for ($i = 0; $i < $in_count; $i++)
{
OCIBindByName($stmt,":param$i",&$in_arrays[$i],-1);
//echo $in_arrays[$i]."-------------
";
}
for ($i = 0; $i < $out_count; $i++)
{
$cur = $i + $in_count;
OCIBindByName($stmt,":param$cur",&$out_array[$i],65536);
//echo $out_arrays[$i]."
";
}
if (!OCIExecute($stmt)) { //echo "执行操作失败!"; //echo $sql."
"; OCIFreeStatement($stmt); return false; } OCIFreeStatement($stmt); return true; }