home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / EXAMP4.SQL < prev    next >
Encoding:
Text File  |  1995-05-18  |  1.2 KB  |  43 lines

  1. rem 
  2. rem $Header: examp4.sql 7020100.1 94/09/28 16:39:52 cli Generic<base> $ 
  3. rem 
  4. Rem  Copyright (c) 1991 by Oracle Corporation 
  5. Rem    NAME
  6. Rem      examp4.sql - <one-line expansion of the name>
  7. Rem    DESCRIPTION
  8. Rem      <short description of component this file declares/defines>
  9. Rem    RETURNS
  10. Rem 
  11. Rem    NOTES
  12. Rem      <other useful comments, qualifications, etc.>
  13. Rem    MODIFIED   (MM/DD/YY)
  14. Rem     rvasired   05/12/92 -  Creation 
  15. /*
  16. ** This block finds all employees whose monthly wages (salary plus
  17. ** commission) are higher than $2000.
  18. **
  19. ** An alias is used in the cursor declaration so that the subsequent
  20. ** use of %ROWTYPE is allowed.  (Column names in a cursor declaration
  21. ** must have aliases if they are not simple names.)
  22. **
  23. ** Copyright (c) 1989,1992 by Oracle Corporation
  24. */
  25.  
  26. DECLARE
  27.     CURSOR my_cursor IS SELECT sal + NVL(comm, 0) wages, ename 
  28.         FROM emp;
  29.     my_rec  my_cursor%ROWTYPE;
  30. BEGIN
  31.     OPEN my_cursor;
  32.     LOOP
  33.         FETCH my_cursor INTO my_rec;
  34.         EXIT WHEN my_cursor%NOTFOUND;
  35.         IF my_rec.wages > 2000 THEN
  36.             INSERT INTO temp VALUES (NULL, my_rec.wages,
  37.                 my_rec.ename);
  38.         END IF;
  39.     END LOOP;
  40.     CLOSE my_cursor;
  41. END;
  42. /
  43.