Added p.s. and changed function name to match p.s.

This commit is contained in:
K 2024-11-10 22:10:04 +05:30
parent b5cd49389b
commit 778cf6f892
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F

View File

@ -1,9 +1,11 @@
# P7 - Age_calc function
**Problem statement:** Create a stored function titled 'Age_calc'. Accept the date of birth of a person as a parameter. Calculate the age of the person in years, months and days e.g. 3 years, 2months, 10 days. Return the age in years directly (with the help of Return statement). The months and days are to be returned indirectly in the form of OUT parameters.
## Creating function
```sql
CREATE OR REPLACE FUNCTION P7(
CREATE OR REPLACE FUNCTION Age_calc(
dob IN DATE,
f_month OUT NUMBER,
f_day OUT NUMBER
@ -46,7 +48,7 @@ DECLARE
months NUMBER;
days NUMBER;
BEGIN
years := P7(TO_DATE('2003-12-02', 'YYYY-MM-DD'), months, days);
years := Age_calc(TO_DATE('2003-12-02', 'YYYY-MM-DD'), months, days);
DBMS_OUTPUT.PUT_LINE('Age: ' || years || ' Years ' || months || ' Months ' || days || ' Days.');
END;
/