2

次のトリガーを使用するとエラーが発生します。

create or replace trigger t1
  after insert or update  
     on student_tbl 
  declare
   pragma autonomous_transaction;
    begin
   if inserting then

 insert into stud_fees_details(stud_id,fees_balance,total_fees) 
       select stud_id,course_fees,course_fees from student_tbl s,courses_tbl c where s.stud_standard_id=c.course_id;

 elsif updating('stud_standard_id') then

insert into stud_fees_details(stud_id,fees_balance,total_fees) 
select stud_id,course_fees,course_fees from student_tbl s,courses_tbl c where s.stud_standard_id=c.course_id;

 end if;
end;

ここに画像の説明を入力

エラーは

ORA-06519: アクティブな自律型トランザクションが検出され、ロールバックされました

4

2 に答える 2

4

データベース エラー メッセージ

ORA-06519 : アクティブな自律型トランザクションが検出され、ロールバックされました
原因: 自律型 PL/SQL ブロックから戻る前に、ブロック内で開始されたすべての自律型トランザクションを完了する必要があります (コミットまたはロールバック)。そうでない場合、アクティブな自律型トランザクションは暗黙的にロールバックされ、このエラーが発生します。
処置: 自律型PL/SQLブロックから戻る前に、アクティブな自律型トランザクションが明示的にコミットまたはロールバックされていることを確認してください。

データベース PL/SQL 言語リファレンスの例

-- Autonomous trigger on emp table:

CREATE OR REPLACE TRIGGER log_sal
  BEFORE UPDATE OF salary ON emp FOR EACH ROW
DECLARE
  PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
  INSERT INTO log (
    log_id,
    up_date,
    new_sal,
    old_sal
  )
  VALUES (
    :old.employee_id,
    SYSDATE,
    :new.salary,
    :old.salary
  );
  COMMIT;
END;
/

しかし、@a_horse_with_no_name は、自律的なトランザクションはおそらくここでは適切ではないことをすでに述べています。

自律トランザクション プラグマを削除すると、@GordonLinoff が彼の投稿で対処しているという問題に遭遇する可能性があります。

于 2016-01-17T15:19:48.793 に答える