CREATE OR REPLACE FUNCTION ADAM.fn_fco_cod_super(pch_tipo IN char,
                                                 pch_dato IN char)
  return char as
  vch_codigo char(6);
BEGIN
begin
  SELECT substr(LTRIM(cod_super), 1, 6)
    INTO vch_codigo
    FROM fco_administradoras
   WHERE codigo = pch_dato
     AND tipo = pch_tipo;  
exception
  when no_data_found then
    RETURN NVL(vch_codigo, ' ');
end;
  RETURN NVL(vch_codigo, ' ');
END fn_fco_cod_super;
/
