CREATE FUNCTION max_fpp (text) RETURNS text
    AS 'select fpp_cde from br_prof '
    LANGUAGE sql;


CREATE FUNCTION max_fpp_me () RETURNS date
    AS '
/* This function returns the current fpp me date  */
select me_dte::date
from fpp
where code = max_fpp('''')
'
    LANGUAGE sql;


CREATE FUNCTION max_fpp_ms () RETURNS date
    AS '
/* This function returns the current fpp ms date  */
select me_dte::date 
from (
   select max(code) as code 
from fpp
where code < max_fpp('''')

) as sub, fpp f
where f.code = sub.code

'
    LANGUAGE sql;

