home *** CD-ROM | disk | FTP | other *** search
- rem
- rem $Header: examp8.sql,v 1002800.2 90/01/11 16:56:54 nsalah Exp $ examp8.sql Copyr (c) 1989 Oracle
- rem
- rem V6PLS10028,DISK$DEV2:[PLS1FREEZE.DEMO.10028]
- /*
- ** This block calculates the ratio between the X and Y columns of
- ** the RATIO table. If the ratio is greater than 0.72, then it
- ** inserts the ratio into RESULT_TABLE. Otherwise, it does nothing.
- **
- ** If the denominator is 0, then ZERO_DIVIDE will be raised, and a
- ** 0 will be inserted into RESULT_TABLE as the ratio.
- **
- ** Copyright (c) 1989 by Oracle Corporation
- */
-
- DECLARE
- numerator NUMBER;
- denominator NUMBER;
- the_ratio NUMBER;
- LOWER_LIMIT CONSTANT NUMBER := 0.72;
- SAMP_NUM CONSTANT NUMBER := 132;
- BEGIN
- SELECT x, y INTO numerator, denominator FROM result_table
- WHERE sample_id = SAMP_NUM;
- the_ratio := numerator/denominator;
- IF the_ratio > LOWER_LIMIT THEN
- INSERT INTO ratio VALUES (SAMP_NUM, the_ratio);
- ELSE
- INSERT INTO ratio VALUES (SAMP_NUM, -1);
- END IF;
- COMMIT;
- EXCEPTION
- WHEN ZERO_DIVIDE THEN
- INSERT INTO ratio VALUES (SAMP_NUM, 0);
- COMMIT;
- WHEN OTHERS THEN
- ROLLBACK;
- END;
- /
-