Added p.s. and changed function name to match p.s.
This commit is contained in:
parent
b5cd49389b
commit
778cf6f892
@ -1,9 +1,11 @@
|
|||||||
# P7 - Age_calc function
|
# 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
|
## Creating function
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
CREATE OR REPLACE FUNCTION P7(
|
CREATE OR REPLACE FUNCTION Age_calc(
|
||||||
dob IN DATE,
|
dob IN DATE,
|
||||||
f_month OUT NUMBER,
|
f_month OUT NUMBER,
|
||||||
f_day OUT NUMBER
|
f_day OUT NUMBER
|
||||||
@ -46,7 +48,7 @@ DECLARE
|
|||||||
months NUMBER;
|
months NUMBER;
|
||||||
days NUMBER;
|
days NUMBER;
|
||||||
BEGIN
|
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.');
|
DBMS_OUTPUT.PUT_LINE('Age: ' || years || ' Years ' || months || ' Months ' || days || ' Days.');
|
||||||
END;
|
END;
|
||||||
/
|
/
|
||||||
|
Loading…
Reference in New Issue
Block a user