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_Regenerar_StatusDoc
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ERRORNUMBER int
begin
declare @d bigint
declare docs cursor for
select top 1200 doc_id from led_docs
WHERE LED_SECCION IN ('C','S','E','V') AND doc_id_lista IS NULL AND doc_id IN (
select doc_id from led_docs
where last_modified > (GETDATE()-0.5)
and estado_doc = 'I' AND (status_doc NOT IN ('I','P') OR status_doc IS NULL)
UNION
select doc_id from led_docs
where last_modified > (GETDATE()-0.5)
and estado_doc = 'N' AND (status_doc NOT IN ('N','E') OR status_doc IS NULL)
UNION
select doc_id from led_docs
where last_modified > (GETDATE()-0.5)
and estado_doc = 'R' AND (status_doc <> 'R' OR status_doc IS NULL)
UNION
select doc_id from led_docs
where last_modified > (GETDATE()-0.5)
and estado_doc = 'V' AND (status_doc <> 'V' OR status_doc IS NULL))
order by doc_id desc
open docs
fetch next from docs into @d
while @@fetch_status = 0 begin
exec imperium_status_doc @d
fetch next from docs into @d
end
close docs
deallocate docs
END
end
GO
GO
CREATE OR ALTER PROCEDURE dbo.Imperium_Regenerar_StatusDoc
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ERRORNUMBER int
begin
declare @d bigint
declare docs cursor for
select top 1200 doc_id from led_docs
WHERE LED_SECCION IN ('C','S','E','V') AND doc_id_lista IS NULL AND doc_id IN (
select doc_id from led_docs
where last_modified > (GETDATE()-0.5)
and estado_doc = 'I' AND (status_doc NOT IN ('I','P') OR status_doc IS NULL)
UNION
select doc_id from led_docs
where last_modified > (GETDATE()-0.5)
and estado_doc = 'N' AND (status_doc NOT IN ('N','E') OR status_doc IS NULL)
UNION
select doc_id from led_docs
where last_modified > (GETDATE()-0.5)
and estado_doc = 'R' AND (status_doc <> 'R' OR status_doc IS NULL)
UNION
select doc_id from led_docs
where last_modified > (GETDATE()-0.5)
and estado_doc = 'V' AND (status_doc <> 'V' OR status_doc IS NULL))
order by doc_id desc
open docs
fetch next from docs into @d
while @@fetch_status = 0 begin
exec imperium_status_doc @d
fetch next from docs into @d
end
close docs
deallocate docs
END
end
GO