Hi,
Im using PHP 4.x and the OCI8 interface. I am calling ORACLE PL/SQL stored procedures.
At some points these stored procedures will be returning error messages to the PHP environment either through ORACLE exceptions or by explicitly calling RAISE_APPLICATION_ERROR() from inside the PL/SQL code.
That is all good. The problem being is that when the call to OCIExecute() is done the errors coming from ORACLE are reported back as warnings rather than errors. If I don't suppress warning messages with the @ before OCIExecute() I see the warning message in the browser. The return code from OCIExecute() indicates an error has occured as its FALSE.
However a call to OCIError() indicates that no error has occurred as it also returns FALSE.
I have enabled track_errors in php.ini in a vain hope that $php_errormsg would contain the warning, but alas it doesn't.
Any idea how I can either trap these warnings, or ensure that the warnings are raised as true errors such that OCIError() is able to grab them and allow me to handle them correctly.
Any help is greatly appreciated. A code fragment has been included below.
function add_objective($db_conn)
{
$objective_name = grab_var('name');
$objective_description = grab_var('description');
$objective_topic_area_id = grab_var('topic_area_id');
$stmt = OCIParse( $db_conn,
"begin pkg_objectives.add_objective(:v_name,:v_description,:v_topic_area_id); end;");
OCIBindByName($stmt,"v_name",$objective_name,-1);
OCIBindByName($stmt,"v_description",$objective_description,-1);
OCIBindByName($stmt,"v_topic_area_id",$objective_topic_area_id,-1);
$result = OCIExecute($stmt);
if(!$result)
{
$err = OCIError();
var_dump($err);
echo "<span class=\"error_header\">An error has occurred</span><br>";
echo "<span class=\"error_body\">\n" . $err['code'] . "<br>\n";
echo $err['message'] . "\n</span><br>\n";
global $php_errormsg;
echo $php_errormsg;
}
OCIFreeStatement($stmt);
}