I am new to plsql; I have 2 tables, tableA and tableB.
tableA is my main table. After insert or update on tableA I want to update it with its related table.
For example: tableA has the column named 'GID_FROM_B' and tableB has the column named 'GID'. I can match this table's values with id and counter. According to below table I want to add values of (2, 5, '') to tableA from my interface. And gid_from_b will be updated with trigger. And I wrote the trigger below.
tableA:
id | counter | gid_from_b |
1 3 xyz
tableB:
id | counter | gid |
1 3 xyz
2 5 abc
CREATE OR REPLACE TRIGGER gid_update
AFTER INSERT OR UPDATE ON DBO.TABLEA
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
UPDATE TABLEA
SET GID_FROM_B = TABLEB.GID
WHERE TABLEA.ID = TABLEB.ID AND TABLEA.COUNTER = TABLEB.COUNTER;
END;