forked from srikanthpragada/plsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcedure Change_Manager
More file actions
31 lines (27 loc) · 884 Bytes
/
Procedure Change_Manager
File metadata and controls
31 lines (27 loc) · 884 Bytes
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
create or replace procedure change_manager(p_empid number, p_manager number)
is
v_flag number(1) := 1;
v_dept1 employees.department_id%type;
v_dept2 employees.department_id%type;
begin
select department_id into v_dept1
from employees
where employee_id = p_empid;
v_flag := 2;
select department_id into v_dept2
from employees
where employee_id = p_manager;
if v_dept1 <> v_dept2 then
raise_application_error(-20200,'Employee and Manager do not belong to same department');
else
update employees set manager_id = p_manager
where employee_id = p_empid;
end if;
exception
when no_data_found then
if v_flag = 1 then
raise_application_error(-20111,'Employee not found');
else
raise_application_error(-20112,'Manager not found');
end if;
end;