简体   繁体   English

在Oracle 11g中的触发器中使用提交

[英]Using commit in Trigger in Oracle 11g

I have created the following trigger in oracle- 我已经在oracle-中创建了以下触发器

create or replace TRIGGER TODAY_TD_INSERT AFTER INSERT ON table1 
FOR EACH ROW
DECLARE
BEGIN             
  INSERT INTO table2 (col1
  ,col2
  ,col3
  ) 
  VALUES (:NEW.,col1
  ,:NEW.,col2
  ,:NEW.,col3
  );
END;

So if any data insert in table1 the same data is inserting in table 2 also. 因此,如果在表1中插入任何数据,则同样的数据也在表2中插入。 So my question is do i need commit the data in new table2 ? 所以我的问题是我是否需要在新table2中提交数据? So far i know we cannot use commit from trigger. 到目前为止,我知道我们不能使用触发器提交。

No, you do not. 你不可以。 The session that made the change to the table on which the trigger is placed issues the commit (or rollback), and that applies to all changes made by that session. 对放置触发器的表进行更改的会话将发出提交(或回滚),并且该会话适用于该会话进行的所有更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM