Danh mục

Oracle PL/SQL Language Pocket Reference- P5

Số trang: 50      Loại file: pdf      Dung lượng: 202.35 KB      Lượt xem: 14      Lượt tải: 0    
tailieu_vip

Phí tải xuống: 11,000 VND Tải xuống file đầy đủ (50 trang) 0
Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Oracle PL/SQL Language Pocket Reference- P5: This pocket guide features quick-reference information to help you use Oracles PL/SQL language. It includes coverage of PL/SQL features in the newest version of Oracle, Oracle8i. It is a companion to Steven Feuerstein and Bill Pribyls bestselling Oracle PL/SQL Programming. Updated for Oracle8, that large volume (nearly 1,000 pages) fills a huge gap in the Oracle market, providing developers with a single, comprehensive guide to building applications with PL/SQL and building them the right way. ...
Nội dung trích xuất từ tài liệu:
Oracle PL/SQL Language Pocket Reference- P5 the Oracle7 architecture allows you to embed many of your business rules directly into your database structure, using database triggers, constraints, and stored procedures. In many cases, you will want to let the RDBMS trap and reject invalid database actions. To do this, you need a way to identify application-specific errors and return information about those error back to the client. This kind of error communication is illustrated in Figure 8.2. Figure 8.2: Error communication from server to client I have called this type of exception unnamed and programmer-defined. The programmer-defined aspect should be clear: because the error is application-specific, you cannot expect PL/SQL to have already defined it for you. The reason this type of exception is also unnamed is that you cannot name or declare an exception within a server-based program or database trigger and have the client-side tool handle that named exception. This identifier simply doesnt cross the great divide between client and server. To get around this problem, Oracle provides a special procedure to allow communication of an unnamed, yet programmer-defined, server-side exception: RAISE_APPLICATION_ERROR. (The use of this procedure and exception type is discussed in Section 8.7, Client-Server Error Communication later in this chapter.) The specification for this procedure is as follows: PROCEDURE RAISE_APPLICATION_ERROR (error_number_in IN NUMBER, error_msg_in IN VARCHAR2); where error_number_in is the error number you have assigned to this error. The error_msg_in argument is the message that will be sent back with the error code to the client program. Previous: 8.2 The Oracle PL/SQL Next: 8.4 Determining Exception Section Programming, 2nd Edition Exception-Handling BehaviorPlease purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 8.2 The Exception Section Book Index 8.4 Determining Exception- Handling Behavior The Oracle Library Navigation Copyright (c) 2000 OReilly & Associates. All rights reserved.Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Previous: 8.1 Why Chapter 8 Next: 8.3 Types of Exception Handling? Exception Handlers Exceptions 8.2 The Exception Section A PL/SQL block (of which procedures, functions, and anonymous blocks are all instances) consists of up to four parts: the header, declaration section, execution section, and exception section, as shown in the following anonymous block: DECLARE ... declarations ... BEGIN ... executable statements ... [ EXCEPTION ... exception handlers ... ] END; When an exception is raised within the execution section of a PL/SQL block, control passes to the exception section. PL/SQL then scans through the exception handlers to see if that exception is handled. The syntax for an exception section follows: EXCEPTION WHEN exception_name [ OR exception_name ... ] THEN END; You can have multiple exception handlers in a single exception section. The exception handlers are structured much like a conditional CASE statement, as shown below: The Exception Section An English-like TranslationPlease purchase PDF Split-Merge on www.verypdf.com to remove this watermark. EXCEPTION If the NO_DATA_FOUND exception WHEN NO_DATA_FOUND was raised, then execute the first set of THEN statements. executable_statements1; WHEN payment_overdue If the payment is overdue, then execute THEN the second set of statements. executable_statements2; WHEN OTHERS If any other exception is encountered, THEN then execute the third set of statements. executable_statements3; END; An exception is handled if an exception that is named in a WHEN clause matches the exception that was raised. Notice that the WHEN clause traps errors only by exception name, not by error codes. If a match is found, then the executable statements associated with that exception are run. If the exception that has been raised is not handled or does not match any of the named exceptions, the executable statements associated with the WHEN OTHERS clause -- if present -- will be run. The WHEN OTHERS clause is optional; if it is not present, then any unhandled exception is immediately raised in the enclosing block, if any. If the exception is not handled by any PL/SQL block, then the error number and message are presented directly to the user of the application. The exception is, in other words, unhandled and it disrupts the execution of the application. Previous: 8.1 Why Oracle PL/SQL Next: 8.3 Types of Exception Handling? Programming, 2nd Edition Exceptions 8.1 Why Exception Handling? Book Index 8.3 Types of Exceptions The Oracle Library Navigation Copyright (c) 2000 OReilly & Associates. All rights reserved.Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ...

Tài liệu được xem nhiều: