create or replace trigger user_operation after delete operation_table
declare
begin_date varchar2(100);
end_date varchar2(100);
productID number;
backInt number;
begin
backInt:=0;
select to_char(t.start_date,'yyyy-mm-dd hh24:mi:ss') as  date1,
to_char(t.end_date,'yyyy-mm-dd hh24:mi:ss') as  date2,t.product_id
into begin_date ,end_date ,productID  from st_generateLog t;
createReport(begin_date,end_date,productID,backInt);
end user_operation ;
结果当删除operation_table 时候 执行createreport后报错 说是检测到活动的独立事物处理,已经回退

解决方案 »

  1.   


    create or replace trigger user_operation 
    after delete operation_table
    for each row
    declare
        begin_date varchar2(100);
        end_date varchar2(100);
        productID number;
        backInt number;
    begin
            backInt:=0;
            select to_char(t.start_date,'yyyy-mm-dd hh24:mi:ss'),
                   to_char(t.end_date,'yyyy-mm-dd hh24:mi:ss'),
                   t.product_id
            into begin_date ,end_date ,productID 
            from st_generateLog t;
            --createReport(begin_date,end_date,productID,backInt);
            --触发器里面调用过程?
            --你的过程是干嘛的?
    end user_operation ;
      

  2.   

    一般来说,如果在触发器中执行存储过程
    则你的存储过程不能使用commit。
    除非你声明存储过程为自治事务。
    使用自治事务后记得要commit。
      

  3.   

    在触发器中能够调用存储过程,但如果存储过程要执行commit操作,应该在存储过程中加入pragma autonomous_transaction;(放在变量部分)声明也就是自治事务。
    同时同意楼上的说法。
      

  4.   

    对,在触发器里面有一点要注意,就是在语句块中不能出现有commit,rollback 的事务控制语句;