home *** CD-ROM | disk | FTP | other *** search
- rem
- rem $Header: demo5.sql,v 6.1 90/02/16 18:40:13 nsalah Exp $ demo5.sql Copyr (c) 1989 Oracle
- rem
- rem V6PLS10030,DISK$DEV2:[PLS1FREEZE.DEMO.10030]
- /* SCRIPT: DEMO5 */
- /* This shows the use of exception handlers. The user supplies various */
- /* employee id's in response to SQL*Plus ACCEPT commands. This is set */
- /* up so that the first execution runs without error, the second one */
- /* doesn't find the employee (and invokes the NO_DATA_FOUND exception), */
- /* and the final one finds multiple employees with the same id (which */
- /* will be caught by the OTHERS handler). A TOO_MANY_ROWS exception */
- /* handler could have been used in the last case, but the intent is to */
- /* show how the OTHERS handler works. */
-
- set termout off
- START load_emp
- delete from temp;
- commit;
- set termout on
-
- prompt >>>>> Here's our EMP table. Notice there is 1 employee with employee
- prompt >>>>> number (empno) 7902, none with empno 9999, and 2 with empno 7698:
- set feedback 100
- set pagesize 100
- set NULL ' --'
- select empno, ename, job, sal, comm, deptno from emp order by empno desc;
-
- prompt >>>>> Hit return to load our PL/SQL procedure that takes an employee
- prompt >>>>> number and then finds the corresponding employee name...
- pause
-
- GET demo5_pls
- .
-
- set verify off
- prompt
- accept emp_num prompt '***** Enter an employee id (7902 is suggested) : '
- prompt
- START demo5_pls
- /
-
- prompt >>>>> Hit return to look at the temp table...
- pause
-
- select col1, message from temp;
-
- prompt >>>>> Now let's try it with an employee number that doesn't exist.
- accept emp_num prompt '***** Enter an employee id (9999 is suggested) : '
- prompt
-
- START demo5_pls
- /
-
- prompt >>>>> Hit return to look at the temp table...
- pause
-
- select col1, message from temp;
-
- prompt >>>>> Now let's try it with an employee number to which two employees
- prompt >>>>> are incorrectly assigned.
- accept emp_num prompt '***** Enter an employee id (7698 is suggested) : '
- prompt
-
- START demo5_pls
- /
-
- prompt >>>>> Hit return to look at the temp table...
- pause
-
- select col1, message from temp;
-