Home » Developer & Programmer » Forms » Age
Age [message #451740] Fri, 16 April 2010 08:56 Go to next message
sugarplum19
Messages: 3
Registered: April 2010
Location: uk
Junior Member
How do I create a trigger for the age. I want an alert to appear when the date of birth field is less than the age of 17. The formula is age=sysdate-dateofbirth
Re: Age [message #451741 is a reply to message #451740] Fri, 16 April 2010 09:00 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Is this another oracle forms question?
Re: Age [message #451742 is a reply to message #451741] Fri, 16 April 2010 09:01 Go to previous messageGo to next message
sugarplum19
Messages: 3
Registered: April 2010
Location: uk
Junior Member
yes
Re: Age [message #451745 is a reply to message #451740] Fri, 16 April 2010 10:03 Go to previous messageGo to next message
Michel Cadot
Messages: 68686
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
MONTHS_BETWEEN
Question: how many months are 17 years?

Regards
Michel
Re: Age [message #451769 is a reply to message #451745] Fri, 16 April 2010 13:10 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, that depends on who you are asking. Depends on sex, that is.

If it is a lady /forum/fa/1704/0/ (and we all know that it is impolite to ask her how old she is), the answer would approximately be "28" /forum/fa/1598/0/ and she'll keep on saying that for another decade or so. However, the fact is that women do get older (while us, men, become charming) /forum/fa/1601/0/
Re: Age [message #451771 is a reply to message #451769] Fri, 16 April 2010 13:12 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Oh, yes - forgot to answer the question.

That would be the WHEN-VALIDATE-ITEM trigger. Pseudocode:
if age < 17 then
  message(you are too young)
  raise error
else
  null (or something else, but don't raise an error)
end if


[EDIT: changed "e" to "o"]

[Updated on: Fri, 16 April 2010 13:12]

Report message to a moderator

Re: Age [message #451843 is a reply to message #451771] Sat, 17 April 2010 07:13 Go to previous messageGo to next message
shaz
Messages: 182
Registered: June 2009
Senior Member
Quote:
Well, that depends on who you are asking. Depends on sex, that is.

If it is a lady (and we all know that it is impolite to ask her how old she is), the answer would approximately be "28" and she'll keep on saying that for another decade or so. However, the fact is that women do get older (while us, men, become charming)



What's it?
Re: Age [message #451900 is a reply to message #451843] Sun, 18 April 2010 09:27 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What's what?
Re: Age [message #451922 is a reply to message #451740] Mon, 19 April 2010 00:39 Go to previous messageGo to next message
kundancertain
Messages: 2
Registered: September 2007
Location: delhi
Junior Member


If
sysdate-TO_DATE('08-APR-1984')>6570 then
dbms_output.put_line('Age exceeding...');
end if;

-- 6570 (18*365) above 18 years.
Re: Age [message #451927 is a reply to message #451922] Mon, 19 April 2010 00:50 Go to previous messageGo to next message
Michel Cadot
Messages: 68686
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
1/ '08-APR-1984' is not a date it is a STRING
2/ The question is about 17 years and not 18 years
3/ 6570 is not 18 years for many people
4/ Read the link I provided

Regards
Michel
Re: Age [message #451931 is a reply to message #451927] Mon, 19 April 2010 01:02 Go to previous messageGo to next message
kundancertain
Messages: 2
Registered: September 2007
Location: delhi
Junior Member

if add_months('08-april-1990',(17*12))> sysdate then
dbms_output.put_line('Age exceeding');
end if;
Re: Age [message #451938 is a reply to message #451931] Mon, 19 April 2010 01:22 Go to previous message
Michel Cadot
Messages: 68686
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
'08-april-1990' is still NOT a date.
And what you want to calculate is the difference between the current date and the birth to get the age.
Once again read the link I provided.

Regards
Michel
Previous Topic: FRM-30058: Invalid name for a record group column (merged by CM)
Next Topic: Import from java class into oracle form
Goto Forum:
  


Current Time: Fri Sep 20 09:31:37 CDT 2024