TAILIEUCHUNG - PL/SQL User’s Guide and Reference phần 5

Xác định ngoại lệ người sử dụng PL / SQL cho phép bạn xác định trường hợp ngoại lệ của riêng bạn. Không giống như trường hợp ngoại lệ được xác định trước, trường hợp ngoại lệ do người dùng định nghĩa phải được khai báo và phải được nâng lên một cách rõ ràng bởi báo cáo GÂY. | User-Defined Exceptions User-Defined Exceptions PL SQL lets you define exceptions of your own. Unlike predefined exceptions user-defined exceptions must be declared and must be raised explicitly by RAISE statements. Declaring Exceptions Exceptions can be declared only in the declarative part of a PL SQL block subprogram or package. You declare an exception by introducing its name followed by the keyword EXCEPTION. In the following example you declare an exception named past_due DECLARE past_due EXCEPTION Exception and variable declarations are similar. But remember an exception is an error condition not a data item. Unlike variables exceptions cannot appear in assignment statements or SQL statements. However the same scope rules apply to variables and exceptions. Scope Rules You cannot declare an exception twice in the same block. You can however declare the same exception in two different blocks. Exceptions declared in a block are considered local to that block and global to all its sub-blocks. Because a block can reference only local or global exceptions enclosing blocks cannot reference exceptions declared in a sub-block. If you redeclare a global exception in a sub-block the local declaration prevails. So the sub-block cannot reference the global exception unless it was declared in a labeled block in which case the following syntax is valid The following example illustrates the scope rules DECLARE past_due EXCEPTION acct_num NUMBER BEGIN DECLARE ------------ sub-block begins past_due EXCEPTION -- this declaration prevails acct_num NUMBER Error Handling 6-7 User-Defined Exceptions BEGIN . IF . THEN RAISE past_due -- this is not handled END IF END -------------- sub-block ends EXCEPTION WHEN past_due THEN -- does not handle RAISEd exception . END The enclosing block does not handle the raised exception because the declaration of past_due in the sub-block prevails. Though they share the same name the two past_due exceptions are different

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.