Code with Explicit Handler for Predefined Exception : Handle Exception « PL SQL Programming « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » PL SQL Programming » Handle Exception 
24. 15. 3. Code with Explicit Handler for Predefined Exception
SQL>
SQL> create or replace function f_get_speed(i_Distance NUMBER, i_timeSec NUMBER)
  2  return NUMBER
  3  is
  4     v_out NUMBER;
  5  begin
  6     v_out:= i_distance/i_timeSec;
  7     return v_out;
  8  exception
  9     WHEN ZERO_DIVIDE THEN
 10        dbms_output.put_line('Divide by zero in the F_GET_SPEED');
 11     return null;
 12  end;
 13  /

Function created.

SQL>
SQL>
SQL>
SQL> declare
  2      v_speed NUMBER;
  3  begin
  4      v_speed:=f_get_speed(10,0);
  5  end;
  6  /
Divide by zero in the F_GET_SPEED

PL/SQL procedure successfully completed.

SQL>
24. 15. Handle Exception
24. 15. 1. Code with No Exception Handler
24. 15. 2. Code with Conditional Control to Avoid an Exception
24. 15. 3. Code with Explicit Handler for Predefined Exception
24. 15. 4. Handling an Unnamed Exception
24. 15. 5. Handling a custom exception
24. 15. 6. An example showing continuing program execution after handling exception
24. 15. 7. The OTHERS Exception Handler
24. 15. 8. Assigning a Name to Predefined Exception Code
24. 15. 9. Using SQLCODE for error code and SQLERRM for error message
24. 15. 10. Catch custom exception
24. 15. 11. Handling exceptions without halting the program
24. 15. 12. Select into statement with exception catch statement
24. 15. 13. Check OTHERS exception
24. 15. 14. Error message code and text
24. 15. 15. Using PRAGMA EXCEPTION_INIT
24. 15. 16. NO data found
24. 15. 17. TOO_MANY_ROWS Exception
24. 15. 18. Use a nested block to catch exceptions from singleton SELECT.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.