dbo.arregla_cuit_integrantes_sociedades

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
--[arregla_cuit_integrantes_sociedades]
CREATE OR ALTER PROCEDURE dbo.arregla_cuit_integrantes_sociedades

AS


BEGIN
    SET NOCOUNT ON;
declare @id_cliente int = 7777
declare @fecha_proceso date = convert(date,getdate())
declare @cuit_procesar varchar(20)
declare @cuit_int varchar(20)
DECLARE ProdInfo CURSOR FOR

select cuit from procesos_cuit_enrichment where cliente = 7777 and Fecha_Proceso = '2018-03-06'
OPEN ProdInfo

FETCH NEXT FROM ProdInfo INTO @cuit_procesar

WHILE @@fetch_status = 0

 BEGIN
 declare @cantidad_integrantes int
 declare @cuit_integrante VARCHAR(20)
 declare @cantidad_integrantes_iguales int
  set @cantidad_integrantes = (select count(cuit_int) from sociedades_constituciones where documento_soc = @cuit_procesar and nombre_integrante != '' and cuit_int != '' and len(cuit_int) < 11 )
  if(@cantidad_integrantes > 0)
   begin
    DECLARE cursorIntegrantes CURSOR FOR
    select cuit_int from sociedades_constituciones  where documento_soc = @cuit_procesar and nombre_integrante != '' and cuit_int != '' and len(cuit_int) < 11
    OPEN cursorIntegrantes
    FETCH NEXT FROM cursorIntegrantes INTO @cuit_int
    
    WHILE @@fetch_status = 0
     BEGIN
     set @cantidad_integrantes_iguales  = (select count(identificacion) from padrones where cuerpo_clave = @cuit_int and habilitado = 1)
     if(@cantidad_integrantes_iguales = 1)
     begin
      set @cuit_integrante  = (select identificacion  from padrones where cuerpo_clave = @cuit_int and habilitado = 1)
      update sociedades_constituciones set cuit_int = @cuit_integrante,cuit_integrante = @cuit_integrante, marcado = 1 where cuit_int = @cuit_int 
      --select @cuit_int,@cuit_integrante
     end
     FETCH NEXT FROM cursorIntegrantes INTO @cuit_int
     END
    CLOSE cursorIntegrantes
    DEALLOCATE cursorIntegrantes
   end
   
  FETCH NEXT FROM ProdInfo INTO @cuit_procesar
 END

CLOSE ProdInfo

DEALLOCATE ProdInfo
END

GO

Used By

No items found