Autonomous PL/SQL Blocks (151)

tsinglee發表於2007-11-06

You can call autonomous transactions from within a PL/SQL block. Use the pragma
AUTONOMOUS_TRANSACTION. A pragma is a compiler directive. You can declare the
following kinds of PL/SQL blocks to be autonomous:
■ Stored procedure or function
■ Local procedure or function
■ Package
■ Type method
■ Top-level anonymous block
When an autonomous PL/SQL block is entered, the transaction context of the caller is
suspended. This operation ensures that SQL operations performed in this block (or
other blocks called from it) have no dependence or effect on the state of the caller’s
transaction context.
When an autonomous block invokes another autonomous block or itself, the called
block does not share any transaction context with the calling block. However, when an
autonomous block invokes a non-autonomous block (that is, one that is not declared to
be autonomous), the called block inherits the transaction context of the calling
autonomous block.

自治事務pl/sql塊
1. 在pl/sql塊中可以使用pragma(編譯器指令) AUTONOMOUS_TRANSACTION 來呼叫自治事務
2. 以下型別的pl/sql塊可為自治事務 : 儲存過程或者函式(包括本地) , 包 , 型別方法 , 頂級匿名塊
3. 當一個自治的塊程式結構開始執行時,呼叫者的事務上下文環境就被掛起.這保證了自治事務塊
(或由此自治事務塊呼叫的其他結構)內的 SQL 操作與呼叫者的事務上下文環境相獨立
4. 當一個自治事務塊呼叫其他自治事務塊或其自身時,被呼叫的不會與呼叫者共享任何事務上下文環境.
但當一個自治事務塊呼叫一個非自治事務塊時,被呼叫的程式結構將繼承呼叫者的事務上下文環境.

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10599713/viewspace-980975/,如需轉載,請註明出處,否則將追究法律責任。