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.copyle_cendeu
AS
BEGIN
SET NOCOUNT ON;
declare @hoy date = getdate()
declare @cant bigint = 0,
@r_id_cendeu int,
@r_cuit varchar(20),
@r_situacion char(2)
declare @html table (nombre varchar(100), periodo varchar(20), situacion varchar(2), total decimal(20,2))
declare @html_txt varchar(max)
declare @cuenta1 int
declare @cuenta2 int
-- recorre por monitoreo
DECLARE bn2 CURSOR
FOR
select distinct cuit
from copyle_cuits
OPEN bn2
Fetch next from bn2 INTO @r_cuit
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
DECLARE cendeuc2 CURSOR
FOR
select id_cendeu, situacion
from cendeu_temp
where iden = @r_cuit
and vigente = 1
and (convert(date,created) > '2018-04-01')
set @cuenta1 = 0
set @cuenta2 = 0
OPEN cendeuc2
FETCH next from cendeuc2 INTO @r_id_cendeu, @r_situacion
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
if (CONVERT(int,@r_situacion) > 1)
begin
set @cuenta2 = @cuenta2+1
end
else
begin
set @cuenta1 = @cuenta1+1
end
FETCH next from cendeuc2 INTO @r_id_cendeu, @r_situacion
END
CLOSE cendeuc2
DEALLOCATE cendeuc2
if(@cuenta1 > 0 and @cuenta2 = 0)
begin
update copyle_cuits set situacion = @cuenta1 where cuit = @r_cuit
end
else
begin
update copyle_cuits set situacion = 0 where cuit = @r_cuit
end
FETCH next from bn2 INTO @r_cuit
END
CLOSE bn2
DEALLOCATE bn2
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.copyle_cendeu
AS
BEGIN
SET NOCOUNT ON;
declare @hoy date = getdate()
declare @cant bigint = 0,
@r_id_cendeu int,
@r_cuit varchar(20),
@r_situacion char(2)
declare @html table (nombre varchar(100), periodo varchar(20), situacion varchar(2), total decimal(20,2))
declare @html_txt varchar(max)
declare @cuenta1 int
declare @cuenta2 int
-- recorre por monitoreo
DECLARE bn2 CURSOR
FOR
select distinct cuit
from copyle_cuits
OPEN bn2
Fetch next from bn2 INTO @r_cuit
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
DECLARE cendeuc2 CURSOR
FOR
select id_cendeu, situacion
from cendeu_temp
where iden = @r_cuit
and vigente = 1
and (convert(date,created) > '2018-04-01')
set @cuenta1 = 0
set @cuenta2 = 0
OPEN cendeuc2
FETCH next from cendeuc2 INTO @r_id_cendeu, @r_situacion
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
if (CONVERT(int,@r_situacion) > 1)
begin
set @cuenta2 = @cuenta2+1
end
else
begin
set @cuenta1 = @cuenta1+1
end
FETCH next from cendeuc2 INTO @r_id_cendeu, @r_situacion
END
CLOSE cendeuc2
DEALLOCATE cendeuc2
if(@cuenta1 > 0 and @cuenta2 = 0)
begin
update copyle_cuits set situacion = @cuenta1 where cuit = @r_cuit
end
else
begin
update copyle_cuits set situacion = 0 where cuit = @r_cuit
end
FETCH next from bn2 INTO @r_cuit
END
CLOSE bn2
DEALLOCATE bn2
END
GO
Depends On
2Used By
No items found