Insert trigger is the way to go. e.g.
CREATE trigger test_trig ON table_a AFTER INSERT FOR EACH ROW
BEGIN
-- :NEW is the new row in TABLE_A...
INSERT INTO table_b( table_a_name ) VALUES( :NEW.name );
END;
/
For insert, :NEW is the new row, for update, :OLD is the old row, :NEW the new row, for delete, :OLD is the row deleted (note AFTER action and BEFORE action have different meanings on the triggers....
Main Topics
Browse All Topics





by: seazodiacPosted on 2004-10-15 at 09:13:55ID: 12321140
if table A and table B are totally unassociated, the values for insert to B does not have any bearings with values for insert to A,
then you's better write two sql for each.
if your concern is that you want to make sure they happen together or none
then just make sure they are in the same transaction, like putting them into one procedure
create procedure test
as
begin
insert into A (c,d,e) values (.....)
insert into B(col1, col2) values (entry1, entry2)
end;
/