home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a524 / 37.ddi / demo / examp3.sql < prev    next >
Encoding:
Text File  |  1991-03-04  |  821 b   |  29 lines

  1. rem 
  2. rem $Header: examp3.sql,v 1002100.2 90/01/11 16:54:57 nsalah Exp $ examp3.sql Copyr (c) 1989 Oracle
  3. rem 
  4. rem V6PLS10021,DISK$DEV9:[PLS.DEMO.10021]
  5. /*
  6. ** This block finds the next highest employee in the chain of command
  7. ** above employee number 7902 who has a salary higher than $4,000.
  8. **
  9. ** Copyright (c) 1989 Oracle Corporation
  10. */
  11.  
  12. DECLARE
  13.     salary           emp.sal%TYPE;
  14.     manager          emp.mgr%TYPE;
  15.     lastname         emp.ename%TYPE;
  16.     STARTING_EMPNO   CONSTANT NUMBER(4) := 7902;
  17. BEGIN
  18.     SELECT sal, mgr INTO salary, manager FROM emp
  19.         WHERE empno = STARTING_EMPNO;
  20.     WHILE salary < 4000 LOOP
  21.         SELECT sal, mgr, ename INTO salary, manager, lastname FROM emp
  22.             WHERE empno = manager;
  23.     END LOOP;
  24.  
  25.     INSERT INTO temp VALUES (null, salary, lastname);
  26.     COMMIT;
  27. END;
  28. /
  29.