dbo.sp_comparo_domicilios_universo_paso2

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

2
Name Data Type Length Description
@cliente int 4
@fecha date 3

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*

*/

CREATE OR ALTER PROCEDURE dbo.sp_comparo_domicilios_universo_paso2
@cliente int,
@fecha   date
AS 
BEGIN
    SET NOCOUNT ON;

 declare @id int = null, @resp int = null 
 declare @domicilio1 varchar(500) = null 
 declare @domicilio2 varchar(500) = null 

 DECLARE C_busqueda CURSOR FOR
   select id, domicilio, domicilio_empresa
   from sp_comparo_domicilios_universo a
    where a.cliente = @cliente 
      and a.fecha_proceso = @fecha 
      and es_el_mismo is null 
   
 
 OPEN C_busqueda
 FETCH NEXT FROM C_busqueda INTO @id, @domicilio1, @domicilio2
           
 WHILE @@fetch_status = 0
 BEGIN 
  
  set @resp = 0
  if (isnull(@domicilio1,'') != '' and isnull(@domicilio2,'') != '')
  begin
   exec @resp = [sp_comparo_domicilios] @domicilio1, @domicilio2
  end
  if (@resp = 1) -- son iguales
   update sp_comparo_domicilios_universo set es_el_mismo = 'S' where id = @id 
  else
   update sp_comparo_domicilios_universo set es_el_mismo = 'N' where id = @id 
  
  FETCH NEXT FROM C_busqueda INTO @id, @domicilio1, @domicilio2
          
 END
 CLOSE C_busqueda
 DEALLOCATE C_busqueda

END 

GO

Used By

No items found