[英]After insert in one table, insert into another table in Oracle APEX
What I would like to do is; 我想做的是 after I insert some data into table1, I would like some of that data automatically inserted into table2, such as the primary key from table1 inserted into table2 as a foreign key.
在将一些数据插入到table1中之后,我希望其中一些数据自动插入到table2中,例如将table1中的主键作为外键插入到table2中。
Is this done using a trigger. 使用触发器完成此操作吗? Not sure where to start looking first.
不知道从哪里开始寻找。
Cheers Brian 干杯布莱恩
Yes you can do that through trigger. 是的,您可以通过触发器来做到这一点。 You can do it like this:
您可以这样做:
CREATE OR REPLACE TRIGGER my_trigger
before INSERT ON table1
REFERENCING NEW AS NEW
for each row
BEGIN
insert into table2(fk_column,column1) values(:new.pk_column_of_table1,'value1');
END;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.