I would like to get the specific error message if a query fails in Oracle 10g. For MySQL, PHP has the mysql_error() function that can return details about why a query failed. I check the php.net manual for the oci_execute() function, but from what I see it only returns false on fail.
I tried using oc_error(), but I am not getting anything from it.
Here is a code sample:
$err = array();
$e = 0;
//Cycle through all files and insert new records into database
for($f=0; $f<sizeof($files); $f++)
{
$invoice_number = $files[$f]['invoice_number'];
$sold_to = $files[$f]['sold_to'];
$date = $files[$f]['date'];
$sql = "insert into invoice (dealer_id, invoice_number, invoice_date)
values ('$sold_to', '$invoice_number', '$date')";
$stid = oci_parse($conn, $sql);
$result = oci_execute($stid);
//If query fails
if(!$result)
{
$err[$e] = oci_error();
$e++;
}
}
print_r($err);
Response for print_r($err):
Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => )