-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPLSQL_24.sql
More file actions
33 lines (31 loc) · 1.14 KB
/
Copy pathPLSQL_24.sql
File metadata and controls
33 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
declare
too_high_salary exception;
v_salary_check pls_integer;
begin
select salary into v_salary_check from employees where employee_id = 100;
if v_salary_check > 20000 then
--raise too_high_salary;
raise_application_error(-20243,'The salary of the selected employee is too high!');
end if;
--we do our business if the salary is under 2000
dbms_output.put_line('The salary is in an acceptable range');
exception
when too_high_salary then
dbms_output.put_line('This salary is too high. You need to decrease it.');
end;
----------------- raise inside of the exception section
declare
too_high_salary exception;
v_salary_check pls_integer;
begin
select salary into v_salary_check from employees where employee_id = 100;
if v_salary_check > 20000 then
raise too_high_salary;
end if;
--we do our business if the salary is under 2000
dbms_output.put_line('The salary is in an acceptable range');
exception
when too_high_salary then
dbms_output.put_line('This salary is too high. You need to decrease it.');
raise_application_error(-01403,'The salary of the selected employee is too high!',true);
end;