PRAGMA AUTONOMOUS_TRANSACTION自治事务应用

PRAGMA AUTONOMOUS_TRANSACTION

当前的存储过程作为已有事务的子事务运行,子事务的commit,rollback操作不影响父事务的状态

可以用于

(1)匿名块

(2)触发器

(3)存储过程

 例子:

procedure addRowAutonomous ( pID in TLOG.id%type, pLDate in TLOG.ldate%type, pLHSECS in TLOG.lhsecs%type, pLLEVEL in TLOG.llevel%type, pLSECTION in TLOG.lsection%type, pLUSER in TLOG.luser%type, pLTEXTE in TLOG.ltexte%type ) is PRAGMA AUTONOMOUS_TRANSACTION; begin addRow ( pID => pID, pLDate => pLDate, pLHSECS => pLHSECS, pLLEVEL => pLLEVEL, pLSECTION => pLSECTION, pLUSER => pLUSER, pLTEXTE => pLTEXTE ); commit; exception when others then PLOG.ERROR; rollback; raise; end;

 

自治事务可以用于在客户化程序中记录调试信息

PROCEDURE insert_cux_debug_info( ........ ) IS PRAGMA AUTONOMOUS_TRANSACTION; ........ BEGIN INSERT INTO cux_debug_info VALUES ........; COMMIT; END;

说明:在由需要记录调试信息的地方调用 insert_cux_debug_info。可用来调试程序

你可能感兴趣的:(exception,存储,insert)