Age Calculation Trigger - Help
423995Jun 23 2004 — edited Jun 23 2004I am very new to Oracle (PL/SQL) and cannot seem to get my (previously configured in MS SQL) age calculation trigger successfully ported over to Oracle. After reading, browsing the topics, here's what I came up with:
CREATE OR REPLACE TRIGGER "schema_name"."TRIG_AGECALC" AFTER INSERT OR UPDATE OF "DOB" ON "TABLE_NAME" FOR EACH ROW
begin
update table_name
set age = floor(months_between(sysdate,dob)/12);
end;
I simply need the trigger to calculate the "age" of a person based on the value entered into the DOB column in the table. This should execute for any inserts on the table or for any updates to the DOB field. Am I just going about this all wrong? The trigger compiles successfully and I don't see any errors; however when I insert or update a new record, the calculated age value does not get entered into the age column.
Much appreciation for any help on this....remember, I am brand new to Oracle and was a previous MS SQL user. I am still learning!
Thanks