Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
3| Name | Data Type | Length | Description |
|---|---|---|---|
| @periodo | int | 4 | |
| @IDCliente | int | 4 | |
| @led_seccion | varchar | 1 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.Carga_Led_Compliance_Periodo
@periodo int,
@IDCliente int,
@led_seccion varchar(1)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ERRORNUMBER SMALLINT
if (@periodo is null)
BEGIN
SET @periodo = convert(varchar(4),datepart(year,getdate())) + RIGHT('00' +convert(varchar(2),datepart(month,getdate())),2)
END
/*
select count(distinct LD.tipo_doc) from led_docs LD
inner join led_cliente_contratista LCC on ld.tipo_doc = LCC.tipo_doc
inner join led_contratistas on (led_contratistas.tipo_contratista = LCC.tipo_contratista and led_contratistas.cliente = LCC.cliente)
inner join led_contratista_periodo LCP on (LCP.contratista = LD.contratista and LCP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'C' and LD.periodo = 201608
and LD.compliance_doc = 'V'
select
estado_complianceV = (SELECT count(distinct LD.DOC_ID) from led_docs LD
inner join led_cliente_empleado LCE on ld.tipo_doc = LCE.tipo_doc
inner join led_empleados on (led_empleados.tipo_empleado = LCE.tipo_empleado and led_empleados.cliente = LCE.cliente)
inner join led_empleados_periodo LEP on (LEP.empleado = LD.empleado and LEP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'E' and LD.periodo = 201608
and (LD.compliance_doc = 'V'))
,
estado_complianceR = (SELECT count(distinct LD.DOC_ID) from led_docs LD
inner join led_cliente_empleado LCE on ld.tipo_doc = LCE.tipo_doc
inner join led_empleados on (led_empleados.tipo_empleado = LCE.tipo_empleado and led_empleados.cliente = LCE.cliente)
inner join led_empleados_periodo LEP on (LEP.empleado = LD.empleado and LEP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'E' and LD.periodo = 201608
and (LD.compliance_doc = 'R' or ((LD.compliance_doc = 'B' or LD.compliance_doc IN ('Y','A')) and LD.fecha_tolerancia < getdate())))
,
estado_complianceB = (SELECT count(distinct LD.DOC_ID) from led_docs LD
inner join led_cliente_empleado LCE on ld.tipo_doc = LCE.tipo_doc
inner join led_empleados on (led_empleados.tipo_empleado = LCE.tipo_empleado and led_empleados.cliente = LCE.cliente)
inner join led_empleados_periodo LEP on (LEP.empleado = LD.empleado and LEP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'E' and LD.periodo = 201608
and (LD.compliance_doc = 'B' ))
,
estado_complianceY = (SELECT count(distinct LD.DOC_ID) from led_docs LD
inner join led_cliente_empleado LCE on ld.tipo_doc = LCE.tipo_doc
inner join led_empleados on (led_empleados.tipo_empleado = LCE.tipo_empleado and led_empleados.cliente = LCE.cliente)
inner join led_empleados_periodo LEP on (LEP.empleado = LD.empleado and LEP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'E' and LD.periodo = 201608
and (LD.compliance_doc = 'B' or (LD.compliance_doc IN ('Y','A') and LD.fecha_tolerancia < getdate())))
*/
DECLARE @LastDay_AnyMonth DATETIME
--Last Day of Any Month and Year
DECLARE @dtDate DATETIME, @nextMonth DATETIME, @LastDayNextMonth DATETIME
SET @dtDate = substring(CONVERT(varchar(6),@periodo),1,4) + '-' + substring(CONVERT(varchar(6),@periodo),5,2) + '-01'
SET @nextMonth = DATEADD(mm, 1, @dtDate)
set @LastDay_AnyMonth = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@dtDate)+1,0))
set @LastDayNextMonth = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@nextMonth)+1,0))
DECLARE @tipo_doc INT,@estado_doc VARCHAR(1),@cliente INT,@contratista INT,@empleado INT,@vehiculo INT
DECLARE @contratista_1 INT,@insertado DATETIME,@fecha_tolerancia DATETIME,@compliance_doc VARCHAR(1),@fecha_vigencia DATETIME,@doc_log VARCHAR(150),@grupo_doc INT
DECLARE @estado_complianceV INT
DECLARE @estado_complianceR INT
DECLARE @estado_complianceB INT
DECLARE @estado_complianceY INT
DECLARE @led_seccion_sub varchar(1)
if @led_seccion <> 'S'
BEGIN
DECLARE LedResumenPeriodo Cursor
FOR
/*
select distinct led_contratista_periodo.contratista from led_contratista_periodo
INNER JOIN led_contratistas ON led_contratista_periodo.contratista = led_contratistas.contratista
INNER JOIN led_cliente_contratista ON led_contratistas.cliente = led_cliente_contratista.cliente
where led_contratistas.cliente = @IDCliente
and led_contratista_periodo.periodo = @periodo
*/
select distinct led_contratista_periodo.contratista,@led_seccion AS LED_SECCION from led_contratista_periodo
INNER JOIN led_contratistas ON led_contratista_periodo.contratista = led_contratistas.contratista
INNER JOIN led_cliente_contratista ON led_contratistas.cliente = led_cliente_contratista.cliente
where led_contratistas.cliente = @IDCliente
and led_contratista_periodo.periodo = @periodo
END
if @led_seccion = 'S'
BEGIN
DECLARE LedResumenPeriodo Cursor
FOR
select distinct led_subcontratista_periodo.subcontratista AS CONTRATISTA,'C' AS LED_SECCION from led_subcontratista_periodo
INNER JOIN led_contratistas ON led_subcontratista_periodo.contratista_1 = led_contratistas.contratista
INNER JOIN led_cliente_contratista ON led_contratistas.cliente = led_cliente_contratista.cliente
where led_contratistas.cliente = @IDCliente
and led_subcontratista_periodo.periodo = @periodo
ORDER BY CONTRATISTA DESC
END
Open LedResumenPeriodo
Fetch NEXT FROM LedResumenPeriodo INTO @contratista,@led_seccion_sub
While (@@FETCH_STATUS <> -1)
BEGIN
/*
SELECT @tipo_doc,@estado_doc,@led_seccion,@cliente,@contratista,@empleado,@vehiculo,@periodo,@contratista_1,@insertado,@fecha_tolerancia,@compliance_doc,@fecha_vigencia,@doc_log,@grupo_doc
*/
BEGIN TRY
/*
select @contratista as contratista,
@periodo as periodo,
@led_seccion as led_seccion,
*/
if @led_seccion <> 'P'
BEGIN
SELECT
/*
@estado_complianceV = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and (compliance_doc = 'V' or (compliance_doc = 'B' and fecha_tolerancia > getdate()))),
@estado_complianceR = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and (compliance_doc = 'R' or (compliance_doc = 'B' and fecha_tolerancia < getdate()))),
@estado_complianceB = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and compliance_doc = 'B')
*/
/*
or (compliance_doc = 'B' and fecha_tolerancia > getdate())
*/
@estado_complianceV = (select count(*) as cantV from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (compliance_doc = 'V')),
@estado_complianceR = (select count(*) as cantR from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (compliance_doc = 'R' or ((compliance_doc = 'B' or compliance_doc IN ('Y','A')) and fecha_tolerancia < getdate()))),
@estado_complianceB = (select count(*) as cantB from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and compliance_doc = 'B'),
@estado_complianceY = (select count(*) as cantY from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (((compliance_doc = 'B' or compliance_doc IN ('Y','A')) and fecha_tolerancia > getdate())))
END
if @led_seccion_sub = 'P'
BEGIN
SELECT
/*
@estado_complianceV = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and (compliance_doc = 'V' or (compliance_doc = 'B' and fecha_tolerancia > getdate()))),
@estado_complianceR = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and (compliance_doc = 'R' or (compliance_doc = 'B' and fecha_tolerancia < getdate()))),
@estado_complianceB = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and compliance_doc = 'B')
*/
/*
or (compliance_doc = 'B' and fecha_tolerancia > getdate())
*/
@estado_complianceV = (select count(*) as cantV from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (compliance_doc = 'V')),
@estado_complianceR = (select count(*) as cantR from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (compliance_doc = 'R' or ((compliance_doc = 'B' or compliance_doc IN ('Y','A')) and fecha_tolerancia < getdate()))),
@estado_complianceB = (select count(*) as cantB from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and compliance_doc = 'B'),
@estado_complianceY = (select count(*) as cantY from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (((compliance_doc = 'B' or compliance_doc IN ('Y','A')) and fecha_tolerancia > getdate())))
END
/*
IF @contratista = 924
BEGIN
SELECT @estado_complianceV AS estado_complianceV,
@estado_complianceR AS estado_complianceR,
@estado_complianceB AS estado_complianceB,
@estado_complianceY AS estado_complianceY,
@contratista AS contratista,
@periodo AS periodo,
@led_seccion_sub AS led_seccion_sub
END
*/
/*
delete led_compliance where contratista = @contratista and periodo=@periodo and led_seccion=@led_seccion_sub
if (@estado_complianceR > 0)
begin
/*
delete led_compliance where contratista = @contratista and periodo=@periodo and led_seccion=@led_seccion
*/
insert INTO led_compliance (contratista, periodo, led_seccion,estado_compliance)
VALUES (@contratista,@periodo,@led_seccion_sub,'R')
end
if (@estado_complianceV > 0 AND @estado_complianceR = 0 AND @estado_complianceY = 0)
begin
/*
delete led_compliance where contratista = @contratista and periodo=@periodo and led_seccion=@led_seccion
*/
insert INTO led_compliance (contratista, periodo, led_seccion,estado_compliance)
VALUES (@contratista,@periodo,@led_seccion_sub,'V')
end
/*@estado_complianceV > 0 AND*/
if (@estado_complianceR = 0 AND @estado_complianceY > 0)
begin
/*
delete led_compliance where contratista = @contratista and periodo=@periodo and led_seccion=@led_seccion
*/
insert INTO led_compliance (contratista, periodo, led_seccion,estado_compliance)
VALUES (@contratista,@periodo,@led_seccion_sub,'A')
end
*/
END TRY
BEGIN CATCH
/*
SET @ERRORNUMBER = 1
*/
/*
SELECT @ERRORNUMBER,@tipo_doc,@estado_doc,@led_seccion,@cliente,@contratista,@empleado,@vehiculo,@periodo,@contratista_1,@insertado,@fecha_tolerancia,@compliance_doc,@fecha_vigencia,@doc_log,@grupo_doc
*/
select 'ERROR: insert led_compliance (contratista, periodo, led_seccion,estado_compliance) values('
SELECT @contratista ,@periodo,@led_seccion,'A'
/*
select @tipo_doc,@estado_doc,@led_seccion,@cliente,@contratista,@empleado,@vehiculo,@periodo,@contratista_1,@insertado,@fecha_tolerancia,@compliance_doc,@fecha_vigencia,@doc_log,@grupo_doc
*/
END CATCH
Fetch NEXT FROM LedResumenPeriodo INTO @contratista,@led_seccion_sub
/*
Fetch NEXT FROM LedResumenPeriodo INTO @tipo_doc,@estado_doc,@led_seccion,@cliente,@contratista,@empleado,@vehiculo,@periodo,@contratista_1,@insertado,@fecha_tolerancia,@compliance_doc,@fecha_vigencia,@doc_log,@grupo_doc
*/
END
CLOSE LedResumenPeriodo
DEALLOCATE LedResumenPeriodo
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.Carga_Led_Compliance_Periodo
@periodo int,
@IDCliente int,
@led_seccion varchar(1)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ERRORNUMBER SMALLINT
if (@periodo is null)
BEGIN
SET @periodo = convert(varchar(4),datepart(year,getdate())) + RIGHT('00' +convert(varchar(2),datepart(month,getdate())),2)
END
/*
select count(distinct LD.tipo_doc) from led_docs LD
inner join led_cliente_contratista LCC on ld.tipo_doc = LCC.tipo_doc
inner join led_contratistas on (led_contratistas.tipo_contratista = LCC.tipo_contratista and led_contratistas.cliente = LCC.cliente)
inner join led_contratista_periodo LCP on (LCP.contratista = LD.contratista and LCP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'C' and LD.periodo = 201608
and LD.compliance_doc = 'V'
select
estado_complianceV = (SELECT count(distinct LD.DOC_ID) from led_docs LD
inner join led_cliente_empleado LCE on ld.tipo_doc = LCE.tipo_doc
inner join led_empleados on (led_empleados.tipo_empleado = LCE.tipo_empleado and led_empleados.cliente = LCE.cliente)
inner join led_empleados_periodo LEP on (LEP.empleado = LD.empleado and LEP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'E' and LD.periodo = 201608
and (LD.compliance_doc = 'V'))
,
estado_complianceR = (SELECT count(distinct LD.DOC_ID) from led_docs LD
inner join led_cliente_empleado LCE on ld.tipo_doc = LCE.tipo_doc
inner join led_empleados on (led_empleados.tipo_empleado = LCE.tipo_empleado and led_empleados.cliente = LCE.cliente)
inner join led_empleados_periodo LEP on (LEP.empleado = LD.empleado and LEP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'E' and LD.periodo = 201608
and (LD.compliance_doc = 'R' or ((LD.compliance_doc = 'B' or LD.compliance_doc IN ('Y','A')) and LD.fecha_tolerancia < getdate())))
,
estado_complianceB = (SELECT count(distinct LD.DOC_ID) from led_docs LD
inner join led_cliente_empleado LCE on ld.tipo_doc = LCE.tipo_doc
inner join led_empleados on (led_empleados.tipo_empleado = LCE.tipo_empleado and led_empleados.cliente = LCE.cliente)
inner join led_empleados_periodo LEP on (LEP.empleado = LD.empleado and LEP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'E' and LD.periodo = 201608
and (LD.compliance_doc = 'B' ))
,
estado_complianceY = (SELECT count(distinct LD.DOC_ID) from led_docs LD
inner join led_cliente_empleado LCE on ld.tipo_doc = LCE.tipo_doc
inner join led_empleados on (led_empleados.tipo_empleado = LCE.tipo_empleado and led_empleados.cliente = LCE.cliente)
inner join led_empleados_periodo LEP on (LEP.empleado = LD.empleado and LEP.periodo = 201608)
where LD.contratista = 172 AND LD.LED_SECCION = 'E' and LD.periodo = 201608
and (LD.compliance_doc = 'B' or (LD.compliance_doc IN ('Y','A') and LD.fecha_tolerancia < getdate())))
*/
DECLARE @LastDay_AnyMonth DATETIME
--Last Day of Any Month and Year
DECLARE @dtDate DATETIME, @nextMonth DATETIME, @LastDayNextMonth DATETIME
SET @dtDate = substring(CONVERT(varchar(6),@periodo),1,4) + '-' + substring(CONVERT(varchar(6),@periodo),5,2) + '-01'
SET @nextMonth = DATEADD(mm, 1, @dtDate)
set @LastDay_AnyMonth = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@dtDate)+1,0))
set @LastDayNextMonth = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@nextMonth)+1,0))
DECLARE @tipo_doc INT,@estado_doc VARCHAR(1),@cliente INT,@contratista INT,@empleado INT,@vehiculo INT
DECLARE @contratista_1 INT,@insertado DATETIME,@fecha_tolerancia DATETIME,@compliance_doc VARCHAR(1),@fecha_vigencia DATETIME,@doc_log VARCHAR(150),@grupo_doc INT
DECLARE @estado_complianceV INT
DECLARE @estado_complianceR INT
DECLARE @estado_complianceB INT
DECLARE @estado_complianceY INT
DECLARE @led_seccion_sub varchar(1)
if @led_seccion <> 'S'
BEGIN
DECLARE LedResumenPeriodo Cursor
FOR
/*
select distinct led_contratista_periodo.contratista from led_contratista_periodo
INNER JOIN led_contratistas ON led_contratista_periodo.contratista = led_contratistas.contratista
INNER JOIN led_cliente_contratista ON led_contratistas.cliente = led_cliente_contratista.cliente
where led_contratistas.cliente = @IDCliente
and led_contratista_periodo.periodo = @periodo
*/
select distinct led_contratista_periodo.contratista,@led_seccion AS LED_SECCION from led_contratista_periodo
INNER JOIN led_contratistas ON led_contratista_periodo.contratista = led_contratistas.contratista
INNER JOIN led_cliente_contratista ON led_contratistas.cliente = led_cliente_contratista.cliente
where led_contratistas.cliente = @IDCliente
and led_contratista_periodo.periodo = @periodo
END
if @led_seccion = 'S'
BEGIN
DECLARE LedResumenPeriodo Cursor
FOR
select distinct led_subcontratista_periodo.subcontratista AS CONTRATISTA,'C' AS LED_SECCION from led_subcontratista_periodo
INNER JOIN led_contratistas ON led_subcontratista_periodo.contratista_1 = led_contratistas.contratista
INNER JOIN led_cliente_contratista ON led_contratistas.cliente = led_cliente_contratista.cliente
where led_contratistas.cliente = @IDCliente
and led_subcontratista_periodo.periodo = @periodo
ORDER BY CONTRATISTA DESC
END
Open LedResumenPeriodo
Fetch NEXT FROM LedResumenPeriodo INTO @contratista,@led_seccion_sub
While (@@FETCH_STATUS <> -1)
BEGIN
/*
SELECT @tipo_doc,@estado_doc,@led_seccion,@cliente,@contratista,@empleado,@vehiculo,@periodo,@contratista_1,@insertado,@fecha_tolerancia,@compliance_doc,@fecha_vigencia,@doc_log,@grupo_doc
*/
BEGIN TRY
/*
select @contratista as contratista,
@periodo as periodo,
@led_seccion as led_seccion,
*/
if @led_seccion <> 'P'
BEGIN
SELECT
/*
@estado_complianceV = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and (compliance_doc = 'V' or (compliance_doc = 'B' and fecha_tolerancia > getdate()))),
@estado_complianceR = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and (compliance_doc = 'R' or (compliance_doc = 'B' and fecha_tolerancia < getdate()))),
@estado_complianceB = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and compliance_doc = 'B')
*/
/*
or (compliance_doc = 'B' and fecha_tolerancia > getdate())
*/
@estado_complianceV = (select count(*) as cantV from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (compliance_doc = 'V')),
@estado_complianceR = (select count(*) as cantR from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (compliance_doc = 'R' or ((compliance_doc = 'B' or compliance_doc IN ('Y','A')) and fecha_tolerancia < getdate()))),
@estado_complianceB = (select count(*) as cantB from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and compliance_doc = 'B'),
@estado_complianceY = (select count(*) as cantY from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (((compliance_doc = 'B' or compliance_doc IN ('Y','A')) and fecha_tolerancia > getdate())))
END
if @led_seccion_sub = 'P'
BEGIN
SELECT
/*
@estado_complianceV = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and (compliance_doc = 'V' or (compliance_doc = 'B' and fecha_tolerancia > getdate()))),
@estado_complianceR = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and (compliance_doc = 'R' or (compliance_doc = 'B' and fecha_tolerancia < getdate()))),
@estado_complianceB = (select count(*) as cantV from led_docs where contratista_1 = @contratista AND LED_SECCION = @led_seccion and periodo = @periodo and compliance_doc = 'B')
*/
/*
or (compliance_doc = 'B' and fecha_tolerancia > getdate())
*/
@estado_complianceV = (select count(*) as cantV from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (compliance_doc = 'V')),
@estado_complianceR = (select count(*) as cantR from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (compliance_doc = 'R' or ((compliance_doc = 'B' or compliance_doc IN ('Y','A')) and fecha_tolerancia < getdate()))),
@estado_complianceB = (select count(*) as cantB from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and compliance_doc = 'B'),
@estado_complianceY = (select count(*) as cantY from led_docs where contratista = @contratista AND LED_SECCION = @led_seccion_sub and periodo = @periodo and (((compliance_doc = 'B' or compliance_doc IN ('Y','A')) and fecha_tolerancia > getdate())))
END
/*
IF @contratista = 924
BEGIN
SELECT @estado_complianceV AS estado_complianceV,
@estado_complianceR AS estado_complianceR,
@estado_complianceB AS estado_complianceB,
@estado_complianceY AS estado_complianceY,
@contratista AS contratista,
@periodo AS periodo,
@led_seccion_sub AS led_seccion_sub
END
*/
/*
delete led_compliance where contratista = @contratista and periodo=@periodo and led_seccion=@led_seccion_sub
if (@estado_complianceR > 0)
begin
/*
delete led_compliance where contratista = @contratista and periodo=@periodo and led_seccion=@led_seccion
*/
insert INTO led_compliance (contratista, periodo, led_seccion,estado_compliance)
VALUES (@contratista,@periodo,@led_seccion_sub,'R')
end
if (@estado_complianceV > 0 AND @estado_complianceR = 0 AND @estado_complianceY = 0)
begin
/*
delete led_compliance where contratista = @contratista and periodo=@periodo and led_seccion=@led_seccion
*/
insert INTO led_compliance (contratista, periodo, led_seccion,estado_compliance)
VALUES (@contratista,@periodo,@led_seccion_sub,'V')
end
/*@estado_complianceV > 0 AND*/
if (@estado_complianceR = 0 AND @estado_complianceY > 0)
begin
/*
delete led_compliance where contratista = @contratista and periodo=@periodo and led_seccion=@led_seccion
*/
insert INTO led_compliance (contratista, periodo, led_seccion,estado_compliance)
VALUES (@contratista,@periodo,@led_seccion_sub,'A')
end
*/
END TRY
BEGIN CATCH
/*
SET @ERRORNUMBER = 1
*/
/*
SELECT @ERRORNUMBER,@tipo_doc,@estado_doc,@led_seccion,@cliente,@contratista,@empleado,@vehiculo,@periodo,@contratista_1,@insertado,@fecha_tolerancia,@compliance_doc,@fecha_vigencia,@doc_log,@grupo_doc
*/
select 'ERROR: insert led_compliance (contratista, periodo, led_seccion,estado_compliance) values('
SELECT @contratista ,@periodo,@led_seccion,'A'
/*
select @tipo_doc,@estado_doc,@led_seccion,@cliente,@contratista,@empleado,@vehiculo,@periodo,@contratista_1,@insertado,@fecha_tolerancia,@compliance_doc,@fecha_vigencia,@doc_log,@grupo_doc
*/
END CATCH
Fetch NEXT FROM LedResumenPeriodo INTO @contratista,@led_seccion_sub
/*
Fetch NEXT FROM LedResumenPeriodo INTO @tipo_doc,@estado_doc,@led_seccion,@cliente,@contratista,@empleado,@vehiculo,@periodo,@contratista_1,@insertado,@fecha_tolerancia,@compliance_doc,@fecha_vigencia,@doc_log,@grupo_doc
*/
END
CLOSE LedResumenPeriodo
DEALLOCATE LedResumenPeriodo
END
GO
Depends On
5Used By
No items found