home *** CD-ROM | disk | FTP | other *** search
- rem
- rem $Header: examp12.sql,v 1002100.2 90/01/11 16:59:32 nsalah Exp $ examp12.sql Copyr (c) 1989 Oracle
- rem
- rem V6PLS10021,DISK$DEV9:[PLS.DEMO.10021]
- /*
- ** This block finds all people whose total annual earnings (salary
- ** plus commission) is greater than $2000.00.
- **
- ** An alias is used in the cursor declaration in order that the
- ** subsequent use of %ROWTYPE based on the cursor is allowed.
- ** (All column names in cursor declarations must have aliases if
- ** they are not simple names.)
-
- **
- ** Copyright (c) 1989 by Oracle Corporation
- */
-
- DECLARE
- CURSOR my_cursor IS SELECT sal + NVL(comm,0) wages, ename
- FROM emp;
- my_rec my_cursor%ROWTYPE;
- BEGIN
- OPEN my_cursor;
- LOOP
- FETCH my_cursor INTO my_rec;
- EXIT WHEN my_cursor%NOTFOUND;
- IF my_rec.wages > 2000 THEN
- INSERT INTO temp VALUES (null, my_rec.wages, my_rec.ename);
- END IF;
- END LOOP;
- CLOSE my_cursor;
- END;
- /
-