Bronte1226
Technical User
I am trying to create a trigger involving 2 tables.
If a record is updated or inserted, after the insert I need to update a field in another table. For example if in the first table there is an inserted row then i need the field in the other table to be updated to a particular text string where the id fields that reference each other are equal (for each row) if the field is updated then i need to change the field in the other table to a different string (where the id's are equal again) I have something like this but it isn't working. I think that i am using the if then else statement incorrectly.
CREATE OR REPLACE TRIGGER BOOKS_TRG AFTER INSERT OR
UPDATE OF LEVEL ON BOOKS FOR EACH ROW BEGIN
UPDATE CLIENT
IF CLIENT_BOOK = 'L'
THEN SET CLIENT_BOOK = 'U'
ELSE SET CLIENT_BOOK = 'U'
WHERE CLIENT.CLIENT_ID = BOOKS.CLIENT_ID
END IF;
END;
/
I am new to triggers so I feel lost. Help!
If a record is updated or inserted, after the insert I need to update a field in another table. For example if in the first table there is an inserted row then i need the field in the other table to be updated to a particular text string where the id fields that reference each other are equal (for each row) if the field is updated then i need to change the field in the other table to a different string (where the id's are equal again) I have something like this but it isn't working. I think that i am using the if then else statement incorrectly.
CREATE OR REPLACE TRIGGER BOOKS_TRG AFTER INSERT OR
UPDATE OF LEVEL ON BOOKS FOR EACH ROW BEGIN
UPDATE CLIENT
IF CLIENT_BOOK = 'L'
THEN SET CLIENT_BOOK = 'U'
ELSE SET CLIENT_BOOK = 'U'
WHERE CLIENT.CLIENT_ID = BOOKS.CLIENT_ID
END IF;
END;
/
I am new to triggers so I feel lost. Help!