MyTetra Share
Делитесь знаниями!
Reraising Current Exception with RAISE Statement
Время создания: 22.10.2017 09:45
Раздел: PL/SQL - Задачник - Exceptions
Запись: xintrea/mytetra_db_mcold/master/base/1508654746r3oz1qwepc/text.html на raw.githubusercontent.com

DECLARE

salary_too_high EXCEPTION;

current_salary NUMBER := 20000;

max_salary NUMBER := 10000;

erroneous_salary NUMBER;

BEGIN


BEGIN

IF current_salary > max_salary THEN

RAISE salary_too_high; -- raise exception

END IF;

EXCEPTION

WHEN salary_too_high THEN -- start handling exception

erroneous_salary := current_salary;

DBMS_OUTPUT.PUT_LINE('Salary ' || erroneous_salary ||' is out of range.');

DBMS_OUTPUT.PUT_LINE ('Maximum salary is ' || max_salary || '.');

RAISE; -- reraise current exception (exception name is optional)

END;


EXCEPTION

WHEN salary_too_high THEN -- finish handling exception

current_salary := max_salary;


DBMS_OUTPUT.PUT_LINE (

'Revising salary from ' || erroneous_salary ||

' to ' || current_salary || '.'

);

END;

/

Result:

Salary 20000 is out of range.

Maximum salary is 10000.

Revising salary from 20000 to 10000.

Так же в этом разделе:
 
MyTetra Share v.0.59
Яндекс индекс цитирования