-- Listing 9-2. PL/SQL Code for the ComputeManager Process
begin
    if :P31_JOB = 'PRESIDENT' then
          -- the president has no manager
          :P32_MANAGER := null; 
    elsif :P31_JOB = 'MANAGER' then
          -- a manager's manager is the president
          select EmpNo into :P32_MANAGER
          from EMP
          where Job = 'PRESIDENT';
    else
          -- the employee's manager is the mgr of the dept 
          select EmpNo into :P32_MANAGER
          from EMP
          where Job = 'MANAGER' and DeptNo = :P31_DEPTNO;
    end if;
end;
