dbo.lista_deudores_

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.lista_deudores_  
AS
BEGIN
    SET NOCOUNT ON;
 declare @id int 
 declare @codigo_ent int
 declare @fec_inf int
 declare @iden varchar(20)
 declare @total int = 0
 DECLARE C_cursor CURSOR FOR
  select id, codigo_ent, fec_inf, iden
    from lista_deudores 
   where procesado = 0
   order by id  
     
 OPEN C_cursor
 FETCH NEXT FROM C_cursor INTO @id, @codigo_ent, @fec_inf, @iden
 WHILE @@fetch_status = 0
 BEGIN 
  if not exists (select * from cendeu where iden = @iden and fec_inf = @fec_inf and codigo_ent = @codigo_ent and situacion = 11 and vigente = 1)
  begin
   update lista_deudores set procesado = 1 where id = @id 
  end 
  else 
  begin
   set @total = @total + 1
   
   update cendeu set situacion = 1, modified = '2024-09-20 14:14:14', modified_by = 94437923 where 
     iden = @iden and fec_inf = @fec_inf and codigo_ent = @codigo_ent and situacion = 11 and vigente = 1
   
   update lista_deudores set procesado = 2 where id = @id 
   
  end 
  FETCH NEXT FROM C_cursor INTO @id, @codigo_ent, @fec_inf, @iden
 END  
 CLOSE C_cursor
 DEALLOCATE C_cursor
 select @total as cambiar
END

GO

Used By

No items found