Professional Documents
Culture Documents
Programming Humility:
Dealing with the Reality of Errors
Steven Feuerstein
steven.feuerstein@quest.com
www.quest.com
www.oracleplsqlprogramming
www.qnxo.com
Copyright 2000-2005 Steven Feuerstein - Page 1
Follow-up from this presentation
Deliberate
– The code architecture itself deliberately relies on an exception.
Example: UTL_FILE.GET_LINE exec_ddl_from_file.sql
get_nextline.sf
Unfortunate
– It is an error, but one that is to be expected and may not even
indicate a problem. Example: SELECT INTO ->
NO_DATA_FOUND fullname.pkb
Unexpected
– A "hard" error that indicates a problem within the application.
Example: Primary key lookup raises TOO_MANY ROWS
Copyright 2000-2005 Steven Feuerstein - Page 5 fullname.pkb
What the Exception Section Covers
DECLARE
Declarations
BEGIN
Executable Statements
EXCEPTION
Exception Handlers
END
Copyright 2000-2005 Steven Feuerstein - Page 6
Exceptions and DML
Oracle PL/SQL
Error Management:
Strengths and Weaknesses
BEGIN
IF employee_rp.is_to_young (:new.hire_date)
THEN
RAISE_APPLICATION_ERROR (
-20175, 'You must be at least 18 years old!');
END IF;
BEGIN
IF employee_rp.is_to_young (:new.hire_date)
THEN
qd_runtime.raise_error (
'EMPLOYEE-TOO-YOUNG'
, name1_in => 'LAST_NAME'
, value1_in => :new.last_name);
END IF;