les08 except tellme3





Handling Exceptions










The interactions in this eCourse require Javascript to be enabled.



 

Handling Exceptions: Part 3


previous|next





Example



CREATE OR REPLACE PROCEDURE raise_salary (p_id IN employees.employee_id%TYPE, p_percent IN NUMBER)IS
e_toomuch EXCEPTION;BEGIN
IF p_percent >= .30 THEN
RAISE e_toomuch;
END IF; UPDATE employees SET salary = salary * (1 + p_percent/100) WHERE employee_id = p_id;
EXCEPTION
WHEN e_toomuch THEN
dbms_output.put_line('Amount is too high.');
WHEN OTHERS THEN
dbms_output.put_line('Error: raise not processed.');END raise_salary;/





The exception is defined in the declarative section.
If the raise amount passed into the procedure is greater than .30 (30%), then the error is raised and control of the program passes the the EXCEPTION area.
The EXCEPTION section checks for the error type. If the error raised is e_toomuch, a customized message is displayed.
The OTHERS clause catches for any other exceptions that may occur in this PL/SQL block.








Wyszukiwarka

Podobne podstrony:
les08 except tellme1
les08 except tellme2
les08 pack tellme1
les08 except showme
les08 except whylearnit
les08 man triggers tellme
les08 func cre tellme1
les08 func cre tellme2
les08 pack spec tellme
les08 cre block1 tellme
les08 cre block2 tellme
les08 audit trigger1 tellme
les08 proc cre tellme2
les08 cre anonymous1 tellme
les08 cre triggers tellme
les08 proc cre tellme1
les08 cre dmltriggers1 tellme
les08 pack body tellme
ExceptionDetailMessage

więcej podobnych podstron