Oracle Built−in Packages- P46

Oracle Built−in Packages- P46: 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 lockhandle temp_lockhandle add to end of lockhandle_tbl temp_index 1 lockhandle_tbl temp_index .handle temp_lockhandle lockhandle_tbl temp_index .name lockname_IN END IF RETURN temp_lockhandle END lockhandle The lockhandle function alone is enough to make using named locks much easier. It relieves the programmer of having to create lockhandle variables for each named lock and also guarantees that the ALLOCATE_UNIQUE procedure is called only once per named lock. New named locks can be used immediately without coding supporting routines as these are handled generically in the function. Furthermore the lockhandle function can be invoked directly in calls to REQUEST or CONVERT. In the following procedure the printer_lockname variable holds the name of a lock being used to serialize access to a printer PROCEDURE get_printer_lock lock_status_OUT OUT INTEGER IS BEGIN lock_status_OUT printer_lockname END get_printer_lock get_lock_TF function Applications using DBMS_LOCK usually must check return values from calls to the REQUEST or CONVERT functions to determine if access to the locked resource has been acquired. The dblock package includes a function called get_lock_TF which takes a lockname and lock mode as IN parameters and returns the Boolean value TRUE if the named lock has been acquired in the desired mode. Using get_lock_TF we can write code like the following IF printer_lockname THEN invoke print routine here ELSE cannot print tell user to try later END IF Code like this is far easier to understand and maintain than code that calls DBMS_LOCK programs directly. All the complexity of using DBMS_LOCK is eliminated the program merely calls get_lock_TF and proceeds directly to appropriate logic based on the return value. Here is the body of get_lock_TF Filename on companion disk FUNCTION get_lock_TF lockname_IN IN .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
16    88    2    20-06-2024
7    81    1    20-06-2024
Đã 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.