Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
1| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_cliente | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
--delete from procesos_masivos
--select * from procesos_masivos
/*
exec [procesos_masivos_pendientes] 257829914
*/
CREATE OR ALTER PROCEDURE dbo.procesos_masivos_pendientes
@p_cliente int
AS
BEGIN
BEGIN TRY
SET NOCOUNT ON;
declare @fecha_proceso date = null
declare @mensaje varchar(300) = null
select @fecha_proceso = MAX(fecha_proceso) from procesos_masivos where cliente = @p_cliente
if (@fecha_proceso is null)
begin
select 'No hay nada para procesar' as mensaje, -100 as error, null as pendientes
return
end
/*
update consultar_afip
set procesado = 0
where proceso = 'PROCESOS_MASIVOS'
and ISNULL(procesado,0) = 1 and ISNULL(ierror,0) = 1
and fecha = @fecha_proceso
and cuit in (select cuit
from procesos_masivos
where cliente = @p_cliente
and es_cuit = 1
and fecha_proceso = @fecha_proceso)
*/
declare @cant int =
(select count(*) from consultar_afip
where proceso = 'PROCESOS_MASIVOS'
and ISNULL(procesado,0) = 0
and fecha = @fecha_proceso
and cuit in (select cuit
from procesos_masivos
where cliente = @p_cliente
and es_cuit = 1
and fecha_proceso = @fecha_proceso))
--set @cant =0
if (@cant = 0)
set @mensaje = 'Fecha del último proceso ' + convert(varchar,@fecha_proceso,103) + ' - Finalizó consultas AFIP '
else
set @mensaje = 'Fecha del último proceso ' + convert(varchar,@fecha_proceso,103) + ' - Registros pendientes de consultar AFIP: ' + convert(varchar,@cant)
select 0 as error, @cant as pendientes,
@mensaje as mensaje
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() as error, 'Error #' + CONVERT(varchar,ERROR_NUMBER()) as mensaje, null as pendientes
END CATCH
END
GO
GO
--delete from procesos_masivos
--select * from procesos_masivos
/*
exec [procesos_masivos_pendientes] 257829914
*/
CREATE OR ALTER PROCEDURE dbo.procesos_masivos_pendientes
@p_cliente int
AS
BEGIN
BEGIN TRY
SET NOCOUNT ON;
declare @fecha_proceso date = null
declare @mensaje varchar(300) = null
select @fecha_proceso = MAX(fecha_proceso) from procesos_masivos where cliente = @p_cliente
if (@fecha_proceso is null)
begin
select 'No hay nada para procesar' as mensaje, -100 as error, null as pendientes
return
end
/*
update consultar_afip
set procesado = 0
where proceso = 'PROCESOS_MASIVOS'
and ISNULL(procesado,0) = 1 and ISNULL(ierror,0) = 1
and fecha = @fecha_proceso
and cuit in (select cuit
from procesos_masivos
where cliente = @p_cliente
and es_cuit = 1
and fecha_proceso = @fecha_proceso)
*/
declare @cant int =
(select count(*) from consultar_afip
where proceso = 'PROCESOS_MASIVOS'
and ISNULL(procesado,0) = 0
and fecha = @fecha_proceso
and cuit in (select cuit
from procesos_masivos
where cliente = @p_cliente
and es_cuit = 1
and fecha_proceso = @fecha_proceso))
--set @cant =0
if (@cant = 0)
set @mensaje = 'Fecha del último proceso ' + convert(varchar,@fecha_proceso,103) + ' - Finalizó consultas AFIP '
else
set @mensaje = 'Fecha del último proceso ' + convert(varchar,@fecha_proceso,103) + ' - Registros pendientes de consultar AFIP: ' + convert(varchar,@cant)
select 0 as error, @cant as pendientes,
@mensaje as mensaje
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() as error, 'Error #' + CONVERT(varchar,ERROR_NUMBER()) as mensaje, null as pendientes
END CATCH
END
GO
Depends On
2Used By
No items found