Tutorial by Examples

What is an exception? Exception in PL/SQL is an error created during a program execution. We have three types of exceptions: Internally defined exceptions Predefined exceptions User-defined exceptions What is an exception handling? Exception handling is a possibility to keep o...
The general syntax for exception section: declare declaration Section begin some statements exception when exception_one then do something when exception_two then do something when exception_three then do something when others then ...
An internally defined exception doesn't have a name, but it has its own code. When to use it? If you know that your database operation might raise specific exceptions those which don't have names, then you can give them names so that you can write exception handlers specifically for them. Otherwis...
Predefined exceptions are internally defined exceptions but they have names. Oracle database raise this type of exceptions automatically. Example create or replace procedure insert_emp is begin insert into emp (emp_id, ename) values ('1','Jon'); exception when dup_val_on_index then ...
As the name suggest user defined exceptions are created by users. If you want to create your own exception you have to: Declare the exception Raise it from your program Create suitable exception handler to catch him. Example I want to update all salaries of workers. But if there are no work...
To illustrate this, here is a function that has 3 different "wrong" behaviors the parameter is completely stupid: we use a user-defined expression the parameter has a typo: we use Oracle standard NO_DATA_FOUND error another, but not handled case Feel free to adapt it to your standa...
Each standard Oracle error is associated with an error number. It's important to anticipate what could go wrong in your code. Here for a connection to another database, it can be: -28000 account is locked -28001 password expired -28002 grace period -1017 wrong user / password Here is a way ...

Page 1 of 1