TAILIEUCHUNG - Oracle Built−in Packages- P6

Oracle Built−in Packages- P6: Ah, for the good old days of Version of PL /SQL! Life was so simple then. No stored procedures or functions and certainly no packages. You had your set of built−in functions, like SUBSTR and TO_DATE. You had the IF statement and various kinds of loops. With these tools at hand, you built your batch−processing scripts for execution in SQL*Plus, and you coded your triggers in SQL*Forms , and you went home at night content with a good day's work done. | Appendix A What s on the Companion Disk PROCEDURE capture IS BEGIN last_timing END PROCEDURE show_elapsed IS BEGIN - last_timing END END tmr The program is a function from the built-in package DBMS_UTILITY which returns the number of hundredths of seconds that have elapsed since an arbitrary point in time. DBMS_OUTPUT is another built-in package its PUT_LINE procedure displays output from a PL SQL program to your screen. Notice that there is another code element defined inside the package body besides the capture and show_elapsed procedures the last_timing variable. This variable holds the timing value from the last call to . Since last_timing does not appear in the package specification an external program . one that is not defined in this package cannot directly reference that variable. This restriction is illustrated in the Booch diagram 2 Figure . 2 This diagram is named after Grady Booch who pioneered many of the ideas of the package particularly in the context of object-oriented design. Figure Booch diagram of tmr package So if I try to access the last_timing variable from outside the tmr package I get an error. This is shown as follows SQL exec 100 begin 100 end ERROR at line 1 ORA-06550 line 1 column 14 PLS-00302 component LAST_TIMING must be declared Why should you or anyone else care about where you define the last_timing variable Because it illustrates a critical aspect of a package s value integrity. If I had placed the variable in the specification then a user of the package could write over the value of last_timing and completely invalidate the integrity of the package. Suppose my package specification looked like this PACKAGE tmr IS last_timing NUMBER PROCEDURE capture PROCEDURE show_elapsed Controlling Access with Packages 16 Appendix A What s on the Companion Disk END tmr The package compiles and seems .

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.