dbo.LN_Fidecheck_ws_select

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

1
Name Data Type Length Description
@p_lista varchar -1

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
select * from LN_Fidecheck_ws where tipofuente = 'Sancionados'
LN_Fidecheck_ws_select '313279,313280'
select distinct tipofuente from LN_Fidecheck_ws
*/


CREATE OR ALTER PROCEDURE dbo.LN_Fidecheck_ws_select 
@p_lista varchar(max) 
   
AS

BEGIN
    SET NOCOUNT ON;
 
 select 
   b.id_resultado, 
   b.cuit,
   b.nombre_persona,
   b.id_padron,
   b.webservice,
   b.StatusCode,
   b.Status,
   b.Reason, 
   b.Id, 
   b.Fuente, 
   b.NombreModificado, 
   b.DocumentoBuscado,
   b.NombreBuscado,
   b.Documento,
   --b.TipoFuente,
   b.Residencia,
   b.DescripcionPais,
   b.PaisNoColaborativo,
   b.Hallazgos,
   b.ExisteDocumentacion,
   b.PorcentajeSimilitud,
   b.fidecheck, 
   a.Codigo,
   case  
    when b.TipoFuente like 'Noticia%' then convert(date,'2000-01-01') -- (para que las noticias las deje ultimas)
    else isnull(a.FechaNovedad,convert(date,'2000-01-01'))
   end as FechaNovedad, 
   convert(varchar(10),convert(date,isnull(a.FechaNovedad,convert(date,'2000-01-01'))),103) as FechaNovedaddmy,
   iif(a.Cargo='NAN',null,a.Cargo) as Cargo,
   iif(a.Institucion='NAN',null,a.Institucion) as Institucion,
   a.Domicilio,
   a.NumeroDocumento,
   a.NumeroIdTributaria,
   a.Url, 
   isnull(a.Relacion,'') as Relacion,  
   case  

   when b.TipoFuente like 'Terrorista%' or b.TipoFuente = 'TER' then 1 -- Positive
   when b.TipoFuente like 'Sancionado%' or b.TipoFuente = 'SAN' then 2 -- Positive
   when b.TipoFuente in ('Sujeto Obligado','Sujetos Obligados','SO') then 9 -- Sujeto Obligado
   when isnull(a.relacion,'') != '' then 4 -- Relacionado
   when b.TipoFuente like 'Noticia%' then 10 -- (para que las noticias las deje ultimas) 
   else 3 -- PEP

   end as orden,
   case 
        when b.TipoFuente  like 'Sancionado%' then 
      case b.fuente 
       when 'INHABIL_CAMBIOS' then b.tipoFuente + ' (Inhabilitados para operaciones de cambio B.C.R.A.)'
       when 'BCRA_SO'         then b.tipoFuente + ' (B.C.R.A.)'
       when 'AFIP_EMP_APOC'   then b.tipoFuente + ' (Empresas con Facturación Apocrifas)'
      else b.tipoFuente
     end
    else b.TipoFuente 
   end as TipoFuente, 
   iif((isnull(a.Cargo,'NAN') != 'NAN' or isnull(a.Institucion,'NAN') != 'NAN'),'si','no') as con_datos, 
   iif(B.modified is not null, convert(varchar,B.modified, 103), convert(varchar,B.created,103)) as fecha 
   
 from LN_Fidecheck_ws B
 left join LN_Fidecheck_ws_mas_datos A on A.id_resultado = B.id_resultado
 INNER JOIN dbo.DelimitedSplit8K(@p_lista, ',') lista ON lista.item = B.id_resultado
 where B.visible = 1 --and (documento = DocumentoBuscado or documento is null) /* Lo sacamos el 08/09/2021 */
 order by con_datos desc, orden asc, isnull(a.FechaNovedad,convert(date,'2000-01-01')) desc
END 
/*
PUJOL JORGE ANDRES - 20051024487
*/


/*
select LN_Fidecheck_ws.tipoFuente f, Relacion a, * from LN_Fidecheck_ws
inner join LN_Fidecheck_ws_mas_datos on LN_Fidecheck_ws_mas_datos.id_resultado = LN_Fidecheck_ws.id_resultado
where Relacion is not null
*/

/*

select * from LN_Fidecheck_ws
where cuit = '23167653669'
order by id_resultado desc
*/


GO

Used By

No items found