dbo.procesamiento_insur_check

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
-- =============================================
-- Author: <Maria Ines Soria>
-- Create date: <23/11/2017>
-- Description: <Controla si el procesamiento de insur finalizo, esta corriendo, o se quedo colgado>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.procesamiento_insur_check  
AS
BEGIN
 SET NOCOUNT ON;
 declare @fin datetime = null
 declare @cant1 int = 0
 declare @cant2 int = 0
 if ((select count(*) from insur_totales where fecha = CAST(GETDATE() AS date))) = 0
  begin
   select 'NO HAY PROCESO' as estado
     end 
 else 
  begin
   set @fin = (select hora_fin from insur_totales 
       where fecha = CAST(GETDATE() AS date))
   if (@fin is not null) 
      begin
      select 'FIN' as estado
      end 
   else 
      begin   
     set @cant1 = (select cantidad_procesada from insur_totales 
           where fecha = CAST(GETDATE() AS date))
     WAITFOR DELAY '00:00:15' -- espera 15 segundos
     set @cant2 = (select cantidad_procesada from insur_totales 
           where fecha = CAST(GETDATE() AS date))
     if (@cant1 = @cant2) 
        begin
       select 'COLGADO' as estado
        end 
     else 
        begin
       select 'CORRIENDO' as estado
        end
      end 
    end 
END

GO

Depends On

1

Used By

No items found