home *** CD-ROM | disk | FTP | other *** search
- rem
- rem $Header: examp3.sql,v 1002100.2 90/01/11 16:54:57 nsalah Exp $ examp3.sql Copyr (c) 1989 Oracle
- rem
- rem V6PLS10021,DISK$DEV9:[PLS.DEMO.10021]
- /*
- ** This block finds the next highest employee in the chain of command
- ** above employee number 7902 who has a salary higher than $4,000.
- **
- ** Copyright (c) 1989 Oracle Corporation
- */
-
- DECLARE
- salary emp.sal%TYPE;
- manager emp.mgr%TYPE;
- lastname emp.ename%TYPE;
- STARTING_EMPNO CONSTANT NUMBER(4) := 7902;
- BEGIN
- SELECT sal, mgr INTO salary, manager FROM emp
- WHERE empno = STARTING_EMPNO;
- WHILE salary < 4000 LOOP
- SELECT sal, mgr, ename INTO salary, manager, lastname FROM emp
- WHERE empno = manager;
- END LOOP;
-
- INSERT INTO temp VALUES (null, salary, lastname);
- COMMIT;
- END;
- /
-