create or replace function fn_fco_ing_afp(p_compania   in char,
                                               p_trabajador in char,
                                               p_periodo    in char)
  return varchar2 is
  Result varchar2(1) := ' ';
  cursor c1 is
    select 'X'
      from vw_fco_hist_traslados_fpo x
     where x.compania = p_compania
       and x.trabajador = p_trabajador
       and to_char(x.fecha_alta, 'YYYYMM') = p_periodo
       order by x.fecha_alta desc;
begin
  open c1;
  fetch c1
    into Result;
  close c1;
  return(nvl(Result, ' '));
end fn_fco_ing_afp;
/
