declare
eer exception;
pragma exception_init (eer,-2292); begin
delete from dept
where dept_no =&pn; commit; exception when eer then
DBMS_OUTPUT.PUT_LINE('Cannot remove dept ' || to_char(&pn) || '. employee exist.'); end;
3. User-defined error.
Declare within the declarative section, and raise explicitly. 例: DECLARE
e_invalid_dpt exception; begin
UPDATE dept
SET dept_name =&p_dept_desc WHERE dept_no = &p_dept_id; IF SQL%NOTFOUND THEN RAISE e_invalide_dpt; END IF; COMMIT; EXCEPTION
WHEN e_invalide_dpt THEN
DBMS_OUTPUT.PUT_LINE(‘NO SUCH DEPARTMENT ID!’); END;
Chapter 9 creating procedures
After completing this lesson, you should be able to do the following:
Distinguish anonymous PL/SQL blocks from named PL/SQL blocks(subprograms) List the benefits of using subprograms
List the different environments from which subprograms can be invoked.
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新人文社科Oracle9i笔记1(23)全文阅读和word下载服务。
相关推荐: