Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
1| Name | Data Type | Length | Description |
|---|---|---|---|
| @fecha_char | varchar | 23 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.cendeu_a_informix
@fecha_char varchar(23) = null -- Sin parametros toma las deudas cargados en las ultimas 26 horas
AS
BEGIN
declare @fecha datetime
if (@fecha_char = '' or @fecha_char is null)
begin
set @fecha = dateadd(hour,(-26), convert(datetime, getdate()))
end
else
begin
set @fecha = CONVERT(datetime, @fecha_char)
end
-- select @fecha
-- De los nuevos trae toda la historia desde 2016-11
select '' as c01_codigo,
iden as cuit,
substring(fec_inf,1,4)+'-'+substring(fec_inf,5,2) as periodo,
convert(int,codigo_ent) as entidad,
convert(int,situacion) as situacion,
convert(int,(deuda_total+prestamos+particip+garotor+o_cptos)*10) as total,
'' as procesado
from cendeu
where iden in (select distinct cuit from cuits_led where nuevo = 1)
and vigente = 1
and fec_inf >= '201611'
union
select '' as c01_codigo,
iden as cuit,
substring(fec_inf,1,4)+'-'+substring(fec_inf,5,2) as periodo,
convert(int,codigo_ent) as entidad,
convert(int,situacion) as situacion,
convert(int,(deuda_total+prestamos+particip+garotor+o_cptos)*10) as total,
'' as procesado
from cendeu_temp
where iden in (select distinct cuit from cuits_led where nuevo = 1)
and vigente = 1
and fec_inf >= '201611'
union
-- de todos trae el ultimo dia
select '' as c01_codigo,
iden as cuit,
substring(fec_inf,1,4)+'-'+substring(fec_inf,5,2) as periodo,
convert(int,codigo_ent) as entidad,
convert(int,situacion) as situacion,
convert(int,(deuda_total+prestamos+particip+garotor+o_cptos)*10) as total,
'' as procesado
from cendeu
where iden in (select distinct cuit from cuits_led where nuevo = 0)
and vigente = 1
and created >= @fecha
union
select '' as c01_codigo,
iden as cuit,
substring(fec_inf,1,4)+'-'+substring(fec_inf,5,2) as periodo,
convert(int,codigo_ent) as entidad,
convert(int,situacion) as situacion,
convert(int,(deuda_total+prestamos+particip+garotor+o_cptos)*10) as total,
'' as procesado
from cendeu_temp
where iden in (select distinct cuit from cuits_led where nuevo = 0)
and vigente = 1
and created >= @fecha
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.cendeu_a_informix
@fecha_char varchar(23) = null -- Sin parametros toma las deudas cargados en las ultimas 26 horas
AS
BEGIN
declare @fecha datetime
if (@fecha_char = '' or @fecha_char is null)
begin
set @fecha = dateadd(hour,(-26), convert(datetime, getdate()))
end
else
begin
set @fecha = CONVERT(datetime, @fecha_char)
end
-- select @fecha
-- De los nuevos trae toda la historia desde 2016-11
select '' as c01_codigo,
iden as cuit,
substring(fec_inf,1,4)+'-'+substring(fec_inf,5,2) as periodo,
convert(int,codigo_ent) as entidad,
convert(int,situacion) as situacion,
convert(int,(deuda_total+prestamos+particip+garotor+o_cptos)*10) as total,
'' as procesado
from cendeu
where iden in (select distinct cuit from cuits_led where nuevo = 1)
and vigente = 1
and fec_inf >= '201611'
union
select '' as c01_codigo,
iden as cuit,
substring(fec_inf,1,4)+'-'+substring(fec_inf,5,2) as periodo,
convert(int,codigo_ent) as entidad,
convert(int,situacion) as situacion,
convert(int,(deuda_total+prestamos+particip+garotor+o_cptos)*10) as total,
'' as procesado
from cendeu_temp
where iden in (select distinct cuit from cuits_led where nuevo = 1)
and vigente = 1
and fec_inf >= '201611'
union
-- de todos trae el ultimo dia
select '' as c01_codigo,
iden as cuit,
substring(fec_inf,1,4)+'-'+substring(fec_inf,5,2) as periodo,
convert(int,codigo_ent) as entidad,
convert(int,situacion) as situacion,
convert(int,(deuda_total+prestamos+particip+garotor+o_cptos)*10) as total,
'' as procesado
from cendeu
where iden in (select distinct cuit from cuits_led where nuevo = 0)
and vigente = 1
and created >= @fecha
union
select '' as c01_codigo,
iden as cuit,
substring(fec_inf,1,4)+'-'+substring(fec_inf,5,2) as periodo,
convert(int,codigo_ent) as entidad,
convert(int,situacion) as situacion,
convert(int,(deuda_total+prestamos+particip+garotor+o_cptos)*10) as total,
'' as procesado
from cendeu_temp
where iden in (select distinct cuit from cuits_led where nuevo = 0)
and vigente = 1
and created >= @fecha
END
GO
Depends On
3Used By
No items found