Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create a trigger to insert and update in one statement

378f05fe-21a7-440d-b794-652fe350ecf4Jul 28 2016 — edited Jul 29 2016

Hello everyone,

I need your help to create a trigger into APEX.

The idea is to duplicate all rows from the table A when inserting a row in the table B. The trigger should also include an update statement to only update one column in the table A.

I've tried the following code but unfortunately it doesn't work...

CREATE OR REPLACE TRIGGER  "Insert_update_trigger" 
AFTER
insert on "Table_B"
for each row
BEGIN
insert into Table_A
SELECT *
FROM Table_A
where A.Key is not null;
update Table_B
JOIN Table_A
ON A.SET_ID = B._SET_ID
SET A.SET_ID = B.SET_ID  + 1;
END;

Is there a better way to write this statement? Or at lease a code that works?

Thanks in advance for your help.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2016
Added on Jul 28 2016
4 comments
1,389 views