ORACLE 自治事物 一.问题 (1)现象 一个表A,存在一个触发器,该触发器用来统计表A的数量,并将结果更新到B表.此时,java代码里面调用insert into select 语句,会发生ora-04091错误. (2)分析 Java调用insert into A select from A语句,对于表A来说,同时查询和插入,这个时候,如果A有插入触发器,并统计A表的数量,就存在问题,因为有java事物和触发器事物两个事物存在,就会报错.这时,需要使用到自治事物. 二.ORACLE自…
http://blog.csdn.net/indexman/article/details/7799862 1.什么是Oracle自治事务 在官方文档中,是这样的定义的“Autonomous transactions are independent transactions that can be called from within another transaction.”就是说它被一个事务调用的事务,但它独立于它的父事务提交或回滚. 下面看一个例子 首先创建一张测试表 MIKE@ORA11…
定 义: Autonomous transactions are independent transactions that can be called from within another transaction. à被一个事务调用的事务,但它独立于它的父事务提交或回滚. 注意事项: 必须在匿名块的最高层或者存储过程.函数.数据包或触发的定义部分中,使用PL/SQL中的PRAGMA AUTONOMOUS_TRANSACTION语句必须Commit或Rollback自治事务,否则…
如下,新建两个存储过程: 在主自治事务中,我们插入一条记录,然后在自治事务中,查看表中行数,然后尝试插入三条记录,查看行数,最后rollback 查看行数,最后返回主事务,查看行数. 1.如下代码: --主事务 PROCEDURE p_test_at_and_mt IS cnt NUMBER := -; BEGIN INSERT INTO msg VALUES ('father Record'); SELECT COUNT(*) INTO cnt FROM msg; dbms_output.pu…
1.创建错误日志表: create table REP_LOGS ( log_s_no NUMBER not null, log_date DATE default sysdate not null, log_type ) default 'E' not null, log_node ) not null, log_mesg ) not null ); -- Add comments to the table comment on table REP_LOGS is '系统操作日志信息表'; -…