So ive been given a table containing data with birthdates like 540401-4428 (yymmdd - last four number(personal identity number) Im trying to figure out how Im supposed to use that number to calculate to current age and how many months. At the moment PNR just prints the whole number.
fnamn=firstname
enamn=lastname
PNR = date of birth
Supposed to look something like this:
Maria, Stjärnkvist, 33,5 år.
Leyla, Errstraid, 42,2 år.
Arne, Möller, 76,6 år.
This is how far i've come:
declare
cursor c_användare
is select UPPER(SUBSTR(fnamn,1,1)) || SUBSTR(fnamn,2),Upper(substr(Enamn,1,1))
|| substr(enamn,2) , PNR
from bilägare;
v_fnamn bilägare.fnamn%type;
v_enamn bilägare.enamn%type;
v_pnr bilägare.pnr%type;
begin
if not c_användare%isopen then
open c_användare;
end if;
loop
fetch c_användare
into v_fnamn,v_enamn,v_pnr;
exit when c_användare%notfound;
dbms_output.put_line(v_Fnamn||', '||v_Enamn||', '||v_pnr||'år');
end loop;
close c_användare;
end;