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

  1. rem 
  2. rem $Header: examp12.sql,v 1002100.2 90/01/11 16:59:32 nsalah Exp $ examp12.sql Copyr (c) 1989 Oracle
  3. rem 
  4. rem V6PLS10021,DISK$DEV9:[PLS.DEMO.10021]
  5. /*
  6. ** This block finds all people whose total annual earnings (salary
  7. ** plus commission) is greater than $2000.00.
  8. **
  9. ** An alias is used in the cursor declaration in order that the
  10. ** subsequent use of %ROWTYPE based on the cursor is allowed.
  11. ** (All column names in cursor declarations must have aliases if
  12. ** they are not simple names.)
  13.  
  14. **
  15. ** Copyright (c) 1989 by Oracle Corporation
  16. */
  17.  
  18. DECLARE
  19.     CURSOR my_cursor IS SELECT sal + NVL(comm,0) wages, ename 
  20.         FROM emp;
  21.     my_rec    my_cursor%ROWTYPE;
  22. BEGIN
  23.     OPEN my_cursor;
  24.     LOOP
  25.         FETCH my_cursor INTO my_rec;
  26.         EXIT WHEN my_cursor%NOTFOUND;
  27.         IF my_rec.wages > 2000 THEN
  28.             INSERT INTO temp VALUES (null, my_rec.wages, my_rec.ename);
  29.         END IF;
  30.     END LOOP;
  31.     CLOSE my_cursor;
  32. END;
  33. /
  34.