-- Listing 7-18. Revised PL/SQL Code for the Previous Button, Approach 1
declare
    v_prevEmp number(4,0);
begin
    select PrevEmp
    into v_prevEmp
    from (select EmpNo, lag(EmpNo) over (order by EName) as PrevEmp
          from EMP)
    where EmpNo = :P19_EMPNO;
  
    if v_prevEmp is not null then
          :P19_EMPNO := v_prevEmp;
    end if;
end;

