CREATE METHOD AGE() FOR ADT_PERSONNE
RETURNS INT
SELF AS RESULT
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
RETURN NULL ON NULL INPUT
RETURN INTERVAL YEAR (CURRENT_DATE - ADT_PERSONNE.PSR_DATE_NAISSANCE) -
          CASE WHEN EXTRACT(MONTH FROM ADT_PERSONNE.PSR_DATE_NAISSANCE) 
                       > EXTRACT(MONTH CURENT_DATE) THEN 1
               WHEN EXTRACT(MONTH FROM ADT_PERSONNE.PSR_DATE_NAISSANCE) 
                       = EXTRACT(MONTH CURENT_DATE) AND 
                    EXTRACT(DAY FROM ADT_PERSONNE.PSR_DATE_NAISSANCE) 
                       > EXTRACT(DAY CURENT_DATE) THEN 1
               ELSE 0
          END;
