dbo.Imperium_Crea_Docs_Empleados_faltantes

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

1
Name Data Type Length Description
@cliente int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO

CREATE OR ALTER PROCEDURE  dbo.Imperium_Crea_Docs_Empleados_faltantes

 @cliente int

AS

BEGIN
 SET NOCOUNT ON;

DECLARE @ERRORNUMBER SMALLINT 

DECLARE @IDContratista int

  DECLARE ListaContratistas Cursor
  FOR
  
   select distinct contratista from (
    select le.empleado,le.id_padron,le.contratista,p.nombre_persona, docs.total_docs
    from led_empleados le join padrones p on le.id_padron = p.id_padron
    join led_empleados_periodo lep on le.empleado = lep.empleado

    left outer join
     (select empleado, count(*) as total_docs from led_docs
     where cliente = @cliente
     and periodo = 201704
     and led_seccion = 'E'
     group by empleado) docs on le.empleado = docs.empleado

   where le.cliente = @cliente
   and lep.periodo = 201704
   and docs.total_docs is null
   group by le.empleado,le.id_padron,le.contratista,p.nombre_persona, docs.total_docs) cont


  Open ListaContratistas


  Fetch NEXT FROM ListaContratistas INTO @IDContratista

  While (@@FETCH_STATUS <> -1)
  BEGIN


  BEGIN TRY
   
   exec Imperium_Carga_Docs_Empleados_Contratista 201704,@cliente,@IDContratista,'A'

  END TRY

  BEGIN CATCH

  SET @ERRORNUMBER = 1

  END CATCH

  Fetch NEXT FROM ListaContratistas INTO @IDContratista

  END

  CLOSE ListaContratistas
  DEALLOCATE ListaContratistas

end

GO

Used By

No items found