Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.actualizar_nacimiento_multiples_futuros
AS
BEGIN
SET NOCOUNT ON;
declare @documento int
declare @cuit varchar(20)
DECLARE C_padron CURSOR FOR
select top 5 convert(int, dni) as dni,cuit from temp_nacidos_futuro where anio_nacimiento = 0
OPEN C_Padron
FETCH NEXT FROM C_Padron INTO @documento,@cuit
select @documento, @cuit
WHILE @@fetch_status = 0
BEGIN
/*begin try*/
declare @anio_nacimiento int = 0
declare @apellido varchar(100) = null
declare @apellidos varchar(100) = null
declare @persona_correcta tinyint = 0
DECLARE Multiple CURSOR FOR
select apellidos from padron_electoral where documento = @documento
OPEN Multiple
FETCH NEXT FROM Multiple INTO @apellidos
WHILE @@fetch_status = 0 and @persona_correcta = 0
BEGIN
set @persona_correcta = (select count(*) from padrones where contains(padrones.nombre_persona,@apellidos) and identificacion = @cuit and habilitado = 1)
select @apellidos, @persona_correcta
if(@persona_correcta = 1)
begin
set @anio_nacimiento = (select anio_nacimiento from padron_electoral where documento = @documento and apellidos = @apellidos)
if(@anio_nacimiento is not null)
begin
update temp_nacidos_futuro set anio_nacimiento = @anio_nacimiento where cuit = @cuit
end
end
FETCH NEXT FROM Multiple INTO @apellidos
END
CLOSE Multiple
DEALLOCATE Multiple
if(@persona_correcta = 0)
begin
update temp_nacidos_futuro set anio_nacimiento = 0 where cuit = @cuit
end
/*
end try
begin catch
--error.
select ERROR_MESSAGE()
CLOSE Multiple
DEALLOCATE Multiple
update temp_nacidos_futuro set anio_nacimiento = 0 where cuit = @cuit
end catch
*/
FETCH NEXT FROM C_Padron INTO @documento,@cuit
END
CLOSE C_Padron
DEALLOCATE C_Padron
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.actualizar_nacimiento_multiples_futuros
AS
BEGIN
SET NOCOUNT ON;
declare @documento int
declare @cuit varchar(20)
DECLARE C_padron CURSOR FOR
select top 5 convert(int, dni) as dni,cuit from temp_nacidos_futuro where anio_nacimiento = 0
OPEN C_Padron
FETCH NEXT FROM C_Padron INTO @documento,@cuit
select @documento, @cuit
WHILE @@fetch_status = 0
BEGIN
/*begin try*/
declare @anio_nacimiento int = 0
declare @apellido varchar(100) = null
declare @apellidos varchar(100) = null
declare @persona_correcta tinyint = 0
DECLARE Multiple CURSOR FOR
select apellidos from padron_electoral where documento = @documento
OPEN Multiple
FETCH NEXT FROM Multiple INTO @apellidos
WHILE @@fetch_status = 0 and @persona_correcta = 0
BEGIN
set @persona_correcta = (select count(*) from padrones where contains(padrones.nombre_persona,@apellidos) and identificacion = @cuit and habilitado = 1)
select @apellidos, @persona_correcta
if(@persona_correcta = 1)
begin
set @anio_nacimiento = (select anio_nacimiento from padron_electoral where documento = @documento and apellidos = @apellidos)
if(@anio_nacimiento is not null)
begin
update temp_nacidos_futuro set anio_nacimiento = @anio_nacimiento where cuit = @cuit
end
end
FETCH NEXT FROM Multiple INTO @apellidos
END
CLOSE Multiple
DEALLOCATE Multiple
if(@persona_correcta = 0)
begin
update temp_nacidos_futuro set anio_nacimiento = 0 where cuit = @cuit
end
/*
end try
begin catch
--error.
select ERROR_MESSAGE()
CLOSE Multiple
DEALLOCATE Multiple
update temp_nacidos_futuro set anio_nacimiento = 0 where cuit = @cuit
end catch
*/
FETCH NEXT FROM C_Padron INTO @documento,@cuit
END
CLOSE C_Padron
DEALLOCATE C_Padron
END
GO
Depends On
3Used By
No items found