Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Age Calculation Trigger - Help

423995Jun 23 2004 — edited Jun 23 2004
I 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 21 2004
Added on Jun 23 2004
3 comments
2,075 views