Reputation: 633
So I have a function that given a user id calculates his bmi (body mass index) based on his last weight measuring (I have a table that records all measurings), and I want to code a trigger that everytime a user inserts his weight, the triggers checks if the user bmi is below a limit. The function is ok, but i can't get the trigger to work here's what I have:
1 CREATE OR REPLACE
2 TRIGGER BMITG
3 AFTER INSERT ON WEIGHTS
4 BEGIN
5 IF BMI(USRID)>25
6 THEN raise_application_error(-20001,'Please control your weight.');
7 END IF;
8 END;
But I get the errors: Error(6,3): PL/SQL: Statement ignored Error(6,10): PLS-00201: identifier 'IDENT' must be declared
I think te problem is that the db doesn't know that USRID is the user id of the INSERT that activates the trigger. How can I solve this problem? BTW the table WEIGHTS has a user id (number), a date and a weight (number).
Regards
Upvotes: 1
Views: 710
Reputation: 23747
Try to use :new.id
instead of USRID
and add FOR EACH ROW
.
Upvotes: 1