User's Manual

Further Error Handling
5-22 Oracle Database Express Edition 2 Day Plus PHP Developer Guide Beta Draft
18.
Click Next> to navigate to the last department record, the Accounting department
with ID 110. Try to navigate past the last department record by clicking next.
The error handling prevents navigation past the last department record.
Further Error Handling
Specific Oracle errors can be handled individully. For example, if a new employee is
created by clicking the Insert new employee button on the Employees page, and the
Department ID is changed to a department that doesn't exist, we can trap this error
and display a more meaningful message:
1. Edit anyco.php. Change the error handling in insert_new_emp():
$r = db_execute_statement($conn, $statement, $err, $bindargs);
if ($r) {
construct_employees();
}
else {
if ($err['CODE'] == 2291) { // Foreign key violated
handle_error("Department {$newemp['deptid']} does not yet exist",
$err);
}
else {
handle_error('Cannot insert employee', $err);
}
}
2. Save the changes to your application files. Test the changes by entering the
following URL:
http://localhost/~<username>/chap5/anyco.php
3. In the Department page, click Show Employees.