home *** CD-ROM | disk | FTP | other *** search
- rem
- rem $Header: examp13.sql,v 1002100.2 90/01/11 17:00:21 nsalah Exp $ examp13.sql Copyr (c) 1989 Oracle
- rem
- rem V6PLS10021,DISK$DEV9:[PLS.DEMO.10021]
- /*
- ** This block calculates the total of all the wages (salary and
- ** commission) paid to employees in department 20. It also counts
- ** how many of these people have salaries above $2000.00, and how
- ** many of them have commissions higher than their salaries.
- **
- ** Copyright (c) 1989 by Oracle Corporation
- */
-
- DECLARE
- CURSOR emp_cursor(dnum NUMBER) IS
- SELECT sal, comm FROM emp WHERE deptno = dnum;
- total_wages NUMBER(11,2) := 0;
- high_paid NUMBER(4) := 0;
- higher_comm NUMBER(4) := 0;
- BEGIN
- /* The number of iterations will equal the number of rows *
- * returned by emp_cursor. */
- FOR emp_record IN emp_cursor(20) LOOP
- emp_record.comm := NVL(emp_record.comm, 0);
- total_wages := total_wages + emp_record.sal +
- emp_record.comm;
- IF emp_record.sal > 2000.00 THEN
- high_paid := high_paid + 1;
- END IF;
- IF emp_record.comm > emp_record.sal THEN
- higher_comm := higher_comm + 1;
- END IF;
- END LOOP;
- INSERT INTO temp VALUES (high_paid, higher_comm,
- 'Total Wages: ' || TO_CHAR(total_wages));
- COMMIT;
- END;
- /
-