CREATE OR REPLACE FUNCTION maskcpf(p_cpf text) 
RETURNS text as $BODY$
DECLARE
    v_unmasked text;
BEGIN

    SELECT INTO v_unmasked unmaskCPF( p_cpf ) ;

    RETURN substring( v_unmasked from 1 for 3 ) || '.' 
        || substring( v_unmasked from 4 for 3 ) || '.' 
        || substring( v_unmasked from 7 for 3 ) || '-' 
        || substring( v_unmasked from 10 for 2 );
END;
 $BODY$ language plpgsql;
