see, I have this code in plpgsql:
CREATE OR REPLACE FUNCTION edatAlumne(int id_alumn) RETURNS int AS $$
DECLARE
edat integer;
BEGIN
select extract(year from age(current_date, naixement))
into edat
from alumnes
where id_alumn = id
return edat;
EXCEPTION
IF id_alumn = null THEN
return null;
END;
$$ LANGUAGE plpgsql;
The statement says that I must create a function that must return the age of the student, identifying it through the ID (that part is done), but the problem comes when they mention the exception topic because:
The statement says that the function must return null if the parameter is null or the student does not exist, and that's where I'm lost, since I do not handle the exception issue very well, since I just started, some help?