END;
CURSOR with Subqueries
例:
DECLARE
CURSOR my_cursor IS
SELECT * FROM DEPT D, (SELECT DEPORTNO,COUNT(*) AS STAFF FROM EMP GROUP BY DEPORTNO ) E
WHERE E.DEPORTNO=D.DEPT_NO; begin
for r_cu in my_cursor loop
DBMS_OUTPUT.PUT_LINE(r_cu.dept_name ||' : '||r_cu.staff); end loop; end;
chapter 8 Handing Exceptions
After completing this lesson, you should be able to do the following: Define PL/SQL exceptions
Recognize unhandled exceptions
List and use different types of PL/SQL exception handlers Trap unanticipated errors
Describe the effect of exception propagation in nested blocks Customize PL/SQL exception messages
Handling Exceptions with PL/SQL
An Exception is an identifier in PL/SQL that is raised during execution. How is it raised?
An Oracle error occurs. You raise it explicitly. How do you handle it? Trap it with a handler.
Propagate it to calling environment. Three types of exception
1. Predefined oracle server error
Do not declare and allow the oracle server to raise them implicitly. 2. Nonpredefined oracle server error.
Declare within the declarative section and allow the oracle server to raise them implicitly.
例:(nonpredefined) define pn =10
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新人文社科Oracle9i笔记1(22)全文阅读和word下载服务。
相关推荐: