I have 2 tables:
Chestionar {
id_c pk
punctaj_max
}
Test{
id_t pk
punctaj
id_c fk
}
I want to define a trigger to validate that, before an update, the modified punctaj is between 0 and the punctaj_max from the chestionar table with that id_c.
I tried this but it doesn't work
CREATE OR REPLACE TRIGGER check_val_salary
BEFORE UPDATE of punctaj ON test
FOR EACH ROW
BEGIN
IF :new.punctaj<0 OR :new.punctaj > (Select punctaj_max from chestionar c where c.id_c=:old.id_c)
THEN
RAISE_APPLICATION_ERROR (-20508, 'Punctaj out of bounds');
END;
Any tips please?
1条答案
按热度按时间mv1qrgav1#
Tables and some sample data for
chestionar
:Trigger:
Testing: