dbo.Imperium_Racalcula_Compliance_dev

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.Imperium_Racalcula_Compliance_dev


AS

/*
@Cliente INT,
@Per INT
*/


BEGIN
 SET NOCOUNT ON;

DECLARE @ERRORNUMBER SMALLINT 


DECLARE ImperiumDocs Cursor
FOR
/*
select distinct contratista, periodo,led_seccion from led_DOCS
where last_modified > getdate()-10
*/

/*
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C' and last_modified > getdate()-1
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and last_modified > getdate()-1
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and last_modified > getdate()-1
order by periodo desc
*/


select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C'
and cliente = 9700868
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E'
and cliente = 9700868
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V'
and cliente = 9700868
order by periodo desc



Open ImperiumDocs


DECLARE @ledSeccion varchar(1)
DECLARE @IDContratista INT
DECLARE @IDContratista1 INT
DECLARE @periodo INT

Fetch NEXT FROM ImperiumDocs INTO @IDContratista,@periodo,@ledSeccion,@IDContratista1
While (@@FETCH_STATUS <> -1)
BEGIN

 BEGIN
  EXEC Imperium_Compliance_Periodo_Contratista @periodo,@IDContratista,@ledSeccion
 END
 /*
  BEGIN
  EXEC Imperium_Compliance_Periodo_Contratista @periodo,@IDContratista,'S'
  END
  BEGIN
  EXEC Imperium_Compliance_Periodo_Contratista @periodo,@IDContratista,'E'
  END
  BEGIN 
  EXEC Imperium_Compliance_Periodo_Contratista @periodo,@IDContratista,'V'
  END
  */


Fetch NEXT FROM ImperiumDocs INTO @IDContratista,@periodo,@ledSeccion,@IDContratista1

END

CLOSE ImperiumDocs
DEALLOCATE ImperiumDocs

END

GO

Used By

No items found