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

  1. rem 
  2. rem $Header: examp4.sql,v 1002100.2 90/01/11 16:55:28 nsalah Exp $ examp4.sql Copyr (c) 1989 Oracle
  3. rem 
  4. rem V6PLS10021,DISK$DEV9:[PLS.DEMO.10021]
  5. /*
  6. ** This block does some numeric processing on data that is
  7. ** stored in data_table that comes from experiment #1.  The
  8. ** results are stored in the TEMP table.
  9. **
  10. ** Copyright (c) 1989 Oracle Corporation
  11. */
  12.  
  13. DECLARE
  14.     num1     data_table.n1%TYPE;   -- Declare variables
  15.     num2     data_table.n2%TYPE;   -- to be of same type as
  16.     num3     data_table.n3%TYPE;   -- database columns
  17.     result   temp.col1%TYPE;
  18.     CURSOR c1 IS
  19.         SELECT n1, n2, n3 FROM data_table
  20.             WHERE exper_num = 1;
  21. BEGIN
  22.     OPEN c1;
  23.     LOOP
  24.         FETCH c1 INTO num1, num2, num3;
  25.         EXIT WHEN c1%NOTFOUND;
  26.             -- the c1%NOTFOUND condition evaluates
  27.             -- to TRUE when FETCH finds no more rows
  28.  
  29.             /* calculate and store the results */
  30.         result := num2/(num1 + num3);
  31.         INSERT INTO temp VALUES (result, null, null);
  32.     END LOOP;
  33.     CLOSE c1;
  34.     COMMIT;
  35. END;
  36. /
  37.