In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The code developed by the project is almost impossible to do without BUG, so you need to catch exceptions while the code is running and handle them. PL/SQL uses an exception handling framework to track and respond to errors.
I. the concept of exception handling
Any type of error is treated as a program exception, which may come from errors generated by the system, errors caused by user actions, and warnings issued by the application to the user. If an error occurs in PL/SQL, an exception is thrown and the execution unit in the current PL/SQL block pauses processing. The control turns to the exception handling unit of the current block, and after the exception handling is completed, the control can no longer be returned to the current block, but the control is transferred to the outer bounding block. If the outer bounding block does not handle the exception, the error continues to be thrown to the outer layer until it is thrown to the user.
II. Definition of exception
1. Declare that there is a named exception
You can customize the name of the exception in the declaration section of PL/SQL as follows:
Exception_name EXCEPTION
There are two ways to reference the name of an exception:
Use RAISE exception_name in the execution unit of the code
Use the where statement WHEN exception_name THEN in the exception handling unit.
two。 The exception name is associated with the error code
Oracle only defines the names of some exceptions, and other errors only define an error number and message, which is not easy to read and maintain the code. The EXCEPTION_INIT command associates the name with the internal error code, and once the association is created, the exception can be referenced by name. The declaration section of PL/SQL operates as follows:
Invalid_month EXCEPTION
PRAGMA EXCEPTION_INIT (invalid_month,-1843)
To facilitate referencing common exception names, you can build packages.
3. Throw an exception
There are three ways for programs to throw exceptions:
An exception can be thrown when the database detects an error
Use the RAISE statement to throw an exception
Use the built-in RAISE_APPLICATION_ERROR procedure to throw an exception.
Third, exception handling
Once an exception is thrown, the current PL/SQL block passes control to the exception handling unit. This exception is either handled by the handle in the current PL/SQL block or thrown to the outer block.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.