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

  1. rem
  2. rem $Header: demo5.sql,v 6.1 90/02/16 18:40:13 nsalah Exp $ demo5.sql Copyr (c) 1989 Oracle
  3. rem
  4. rem V6PLS10030,DISK$DEV2:[PLS1FREEZE.DEMO.10030]
  5. /*        SCRIPT: DEMO5                                            */
  6. /* This shows the use of exception handlers.  The user supplies various  */
  7. /* employee id's in response to SQL*Plus ACCEPT commands.  This is set   */
  8. /* up so that the first execution runs without error, the second one     */
  9. /* doesn't find the employee (and invokes the NO_DATA_FOUND exception),  */
  10. /* and the final one finds multiple employees with the same id (which    */
  11. /* will be caught by the OTHERS handler).  A TOO_MANY_ROWS exception     */
  12. /* handler could have been used in the last case, but the intent is to   */
  13. /* show how the OTHERS handler works.                                    */
  14.  
  15. set termout off
  16. START load_emp
  17. delete from temp;
  18. commit;
  19. set termout on
  20.  
  21. prompt >>>>>  Here's our EMP table.  Notice there is 1 employee with employee
  22. prompt >>>>>  number (empno) 7902, none with empno 9999, and 2 with empno 7698:
  23. set feedback 100
  24. set pagesize 100
  25. set NULL '        --'
  26. select empno, ename, job, sal, comm, deptno from emp order by empno desc;
  27.  
  28. prompt >>>>>  Hit return to load our PL/SQL procedure that takes an employee
  29. prompt >>>>>  number and then finds the corresponding employee name...
  30. pause
  31.  
  32. GET demo5_pls
  33. .
  34.  
  35. set verify off
  36. prompt
  37. accept emp_num prompt '*****  Enter an employee id (7902 is suggested) : '
  38. prompt
  39. START demo5_pls
  40. /
  41.  
  42. prompt >>>>>  Hit return to look at the temp table...
  43. pause
  44.  
  45. select col1, message from temp;
  46.  
  47. prompt >>>>>  Now let's try it with an employee number that doesn't exist.
  48. accept emp_num prompt '*****  Enter an employee id (9999 is suggested) : '
  49. prompt
  50.  
  51. START demo5_pls
  52. /
  53.  
  54. prompt >>>>>  Hit return to look at the temp table...
  55. pause
  56.  
  57. select col1, message from temp;
  58.  
  59. prompt >>>>>  Now let's try it with an employee number to which two employees
  60. prompt >>>>>  are incorrectly assigned.
  61. accept emp_num prompt '*****  Enter an employee id (7698 is suggested) : '
  62. prompt
  63.  
  64. START demo5_pls
  65. /
  66.  
  67. prompt >>>>>  Hit return to look at the temp table...
  68. pause
  69.  
  70. select col1, message from temp;
  71.