PL/SQL block to classify people based on ages
Q. Write a PL/SQL block to accept the age of the user, based on the following conditions:
age <13 years child?
age >= 13 years and <20 years, TeenAge?
age >= 21years, Adult?
Answer:
The following code will display
DECLARE age number:=&user_age;
USER varchar(20);
BEGIN IF (age<13) THEN USER:='Child';
elsif (age>12)
AND (age<20) THEN USER:='TeenAge';
ELSE USER:='Adult';
END IF;
dbms_output.put_line('User is '||USER);
END;
/
Output: