Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
3| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_Cuit | varchar | 20 | |
| @nombre | varchar | 1000 | |
| @nombre_contains | varchar | 1000 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
exec api_validacion_cuit '17726090','',''
exec [api_validacion_cuit] '20000591441','PUGLIESE JOSE', '"PUBLIESE*" NEAR "JOSE*"'
*/
CREATE OR ALTER PROCEDURE dbo.api_validacion_cuit
@p_Cuit varchar(20),
@nombre varchar(1000),
@nombre_contains varchar(1000)
AS
BEGIN
SET NOCOUNT ON;
declare @busqueda_igual int,@busqueda_contains int,@nombre_encontrado varchar(1000)
if(@nombre = '')
begin
set @busqueda_igual = (select count(*) from padrones where identificacion = @p_Cuit and habilitado = 1 and identificador in(select identificador from identificadores where country_code = 'AR'))
if(@busqueda_igual = 1)
begin
set @nombre_encontrado = (select nombre_persona from padrones where identificacion = @p_Cuit and habilitado = 1 and identificador in(select identificador from identificadores where country_code = 'AR'))
select 'El cuit fue encontrado con éxito' as mensaje,1 as validacion,@nombre_encontrado as nombre_correcto
end
else if(@busqueda_igual = 0)
begin
select 'El cuit no se encuentra en nuestras bases de datos o es inválido' as mensaje,0 as validacion,'' as nombre_correcto
end
else
begin
select 'ERROR Múltiples resultados para la misma CUIT' as mensaje,0 as validacion,'' as nombre_correcto
end
end
else
begin
set @busqueda_igual = (select count(*) from padrones where identificacion = @p_Cuit and habilitado = 1 and nombre_persona = @nombre and identificador in(select identificador from identificadores where country_code = 'AR'))
if( @busqueda_igual = 1)
begin
select 'El registro es exactamente igual' as mensaje,1 as validacion,'' as nombre_correcto
end
else if(@busqueda_igual = 0)
begin
set @busqueda_contains = (select count(*) from padrones where identificacion = @p_Cuit and habilitado = 1 and contains(nombre_persona,@nombre_contains) and identificador in(select identificador from identificadores where country_code = 'AR'))
if(@busqueda_contains = 1)
begin
set @nombre_encontrado = (select nombre_persona from padrones where identificacion = @p_Cuit and habilitado = 1 and contains(nombre_persona,@nombre_contains) and identificador in(select identificador from identificadores where country_code = 'AR'))
select 'El registro coincide pero con una o más variantes en su nombre' as mensaje,1 as validacion,@nombre_encontrado as nombre_correcto
end
else if(@busqueda_contains = 0)
begin
set @nombre_encontrado = (select nombre_persona from padrones where identificacion = @p_Cuit and habilitado = 1 and identificador in(select identificador from identificadores where country_code = 'AR'))
select 'El par CUIT - nombre no coincide' as mensaje,0 as validacion,@nombre_encontrado as nombre_correcto
end
end
end
END
GO
GO
/*
exec api_validacion_cuit '17726090','',''
exec [api_validacion_cuit] '20000591441','PUGLIESE JOSE', '"PUBLIESE*" NEAR "JOSE*"'
*/
CREATE OR ALTER PROCEDURE dbo.api_validacion_cuit
@p_Cuit varchar(20),
@nombre varchar(1000),
@nombre_contains varchar(1000)
AS
BEGIN
SET NOCOUNT ON;
declare @busqueda_igual int,@busqueda_contains int,@nombre_encontrado varchar(1000)
if(@nombre = '')
begin
set @busqueda_igual = (select count(*) from padrones where identificacion = @p_Cuit and habilitado = 1 and identificador in(select identificador from identificadores where country_code = 'AR'))
if(@busqueda_igual = 1)
begin
set @nombre_encontrado = (select nombre_persona from padrones where identificacion = @p_Cuit and habilitado = 1 and identificador in(select identificador from identificadores where country_code = 'AR'))
select 'El cuit fue encontrado con éxito' as mensaje,1 as validacion,@nombre_encontrado as nombre_correcto
end
else if(@busqueda_igual = 0)
begin
select 'El cuit no se encuentra en nuestras bases de datos o es inválido' as mensaje,0 as validacion,'' as nombre_correcto
end
else
begin
select 'ERROR Múltiples resultados para la misma CUIT' as mensaje,0 as validacion,'' as nombre_correcto
end
end
else
begin
set @busqueda_igual = (select count(*) from padrones where identificacion = @p_Cuit and habilitado = 1 and nombre_persona = @nombre and identificador in(select identificador from identificadores where country_code = 'AR'))
if( @busqueda_igual = 1)
begin
select 'El registro es exactamente igual' as mensaje,1 as validacion,'' as nombre_correcto
end
else if(@busqueda_igual = 0)
begin
set @busqueda_contains = (select count(*) from padrones where identificacion = @p_Cuit and habilitado = 1 and contains(nombre_persona,@nombre_contains) and identificador in(select identificador from identificadores where country_code = 'AR'))
if(@busqueda_contains = 1)
begin
set @nombre_encontrado = (select nombre_persona from padrones where identificacion = @p_Cuit and habilitado = 1 and contains(nombre_persona,@nombre_contains) and identificador in(select identificador from identificadores where country_code = 'AR'))
select 'El registro coincide pero con una o más variantes en su nombre' as mensaje,1 as validacion,@nombre_encontrado as nombre_correcto
end
else if(@busqueda_contains = 0)
begin
set @nombre_encontrado = (select nombre_persona from padrones where identificacion = @p_Cuit and habilitado = 1 and identificador in(select identificador from identificadores where country_code = 'AR'))
select 'El par CUIT - nombre no coincide' as mensaje,0 as validacion,@nombre_encontrado as nombre_correcto
end
end
end
END
GO
Depends On
2Used By
No items found