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
/*
exec bajas_cheques_bcra
*/
CREATE OR ALTER PROCEDURE dbo.bajas_cheques_bcra
AS
BEGIN
declare @id_cheque int,
@cuit_firmante varchar(11),
@cuit_relacionado varchar(11) ,
@nro_cheque int ,
@fecha_rechazo smalldatetime ,
@importe money ,
@id_causa smallint ,
@fecha_levantamiento smalldatetime ,
@fecha_pago smalldatetime ,
@fecha_baja date ,
@procesado char(1)
DECLARE bn CURSOR FOR
select * from ChequesBCRA_bajas where procesado is null
OPEN bn
Fetch next from bn INTO
@id_cheque,
@cuit_firmante,
@cuit_relacionado,
@nro_cheque,
@fecha_rechazo,
@importe,
@id_causa,
@fecha_levantamiento,
@fecha_pago,
@fecha_baja,
@procesado
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
update ChequesBCRA
set visible = 0,
modified = getdate()
where ChequesBCRA.cuit_firmante = @cuit_firmante
AND isnull(ChequesBCRA.cuit_relacionado,'') = isnull(@Cuit_relacionado,'')
AND ChequesBCRA.nro_cheque = @nro_cheque
AND ChequesBCRA.importe = @importe
AND ChequesBCRA.fecha_rechazo = @fecha_rechazo
update ChequesBCRA_bajas
set procesado = 'S'
where id_cheque = @id_cheque
-- wait for 1 second
WAITFOR DELAY '00:00:00.200'
Fetch next from bn INTO
@id_cheque,
@cuit_firmante,
@cuit_relacionado,
@nro_cheque,
@fecha_rechazo,
@importe,
@id_causa,
@fecha_levantamiento,
@fecha_pago,
@fecha_baja,
@procesado
END
CLOSE bn
DEALLOCATE bn
/*
WAITFOR DELAY '00:00:00.100'
*/
delete CHEQ_RECH_BAJAS_20180214
delete chequesbajas2020 where procesado = 1
delete chequesBCRA_txt_bajas where procesado = 1
insert into ChequesBCRA (cuit_firmante, nro_cheque, fecha_rechazo, importe, id_causa, fecha_levantamiento, fecha_pago,
cuit_relacionado, visible, en_revision, multa_no_aplica, suspendido,created, usuarioifx, idifx)
SELECT cuit_firmante, nro_cheque, fecha_rechazo, importe, id_causa, fecha_levantamiento, fecha_pago,
cuit_relacionado, visible, en_revision, multa_no_aplica, suspendido,getdate() as created, usuarioifx, idifx
FROM CHEQ_RECH_20180214
delete CHEQ_RECH_20180214
/* Insertamos las altas
declare @id_chequeA int,
@cuit_firmanteA varchar(11),
@cuit_relacionadoA varchar(11) ,
@nro_chequeA int ,
@fecha_rechazoA smalldatetime ,
@importeA money ,
@id_causaA smallint ,
@fecha_levantamientoA smalldatetime ,
@fecha_pagoA smalldatetime ,
@fecha_bajaA date ,
@procesadoA char(1) ,
@visibleA bit,
@en_revisionA tinyint,
@multa_no_aplicaA tinyint,
@suspendidoA tinyint,
@createdA datetime,
@usuarioifxA varchar(10),
@idifxA int
DECLARE altacheques CURSOR FOR
select id_cheque,cuit_firmante,cuit_relacionado,nro_cheque,fecha_rechazo,importe,id_causa,fecha_levantamiento,fecha_pago,
visible,en_revision,multa_no_aplica,suspendido,created,usuarioifx,idifx from CHEQ_RECH_20180214
OPEN altacheques
Fetch next from altacheques INTO
@id_chequeA,
@cuit_firmanteA,
@cuit_relacionadoA,
@nro_chequeA,
@fecha_rechazoA,
@importeA,
@id_causaA,
@fecha_levantamientoA,
@fecha_pagoA,
@visibleA,
@en_revisionA,
@multa_no_aplicaA,
@suspendidoA,
@createdA,
@usuarioifxA,
@idifxA
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
set @createdA = getdate()
insert into ChequesBCRA (cuit_firmante,cuit_relacionado,nro_cheque,fecha_rechazo,importe,id_causa,fecha_levantamiento,fecha_pago,
visible,en_revision,multa_no_aplica,suspendido,created,usuarioifx,idifx)
values (@cuit_firmanteA,
@cuit_relacionadoA,
@nro_chequeA,
@fecha_rechazoA,
@importeA,
@id_causaA,
@fecha_levantamientoA,
@fecha_pagoA,
@visibleA,
@en_revisionA,
@multa_no_aplicaA,
@suspendidoA,
@createdA,
@usuarioifxA,
@idifxA)
-- wait for 1 second
/*
WAITFOR DELAY '00:00:01'
*/
WAITFOR DELAY '00:00:00.010'
delete CHEQ_RECH_20180214 where id_cheque = @id_chequeA
Fetch next from altacheques INTO
@id_chequeA,
@cuit_firmanteA,
@cuit_relacionadoA,
@nro_chequeA,
@fecha_rechazoA,
@importeA,
@id_causaA,
@fecha_levantamientoA,
@fecha_pagoA,
@visibleA,
@en_revisionA,
@multa_no_aplicaA,
@suspendidoA,
@createdA,
@usuarioifxA,
@idifxA
END
CLOSE altacheques
DEALLOCATE altacheques
*/
END
GO
GO
/*
exec bajas_cheques_bcra
*/
CREATE OR ALTER PROCEDURE dbo.bajas_cheques_bcra
AS
BEGIN
declare @id_cheque int,
@cuit_firmante varchar(11),
@cuit_relacionado varchar(11) ,
@nro_cheque int ,
@fecha_rechazo smalldatetime ,
@importe money ,
@id_causa smallint ,
@fecha_levantamiento smalldatetime ,
@fecha_pago smalldatetime ,
@fecha_baja date ,
@procesado char(1)
DECLARE bn CURSOR FOR
select * from ChequesBCRA_bajas where procesado is null
OPEN bn
Fetch next from bn INTO
@id_cheque,
@cuit_firmante,
@cuit_relacionado,
@nro_cheque,
@fecha_rechazo,
@importe,
@id_causa,
@fecha_levantamiento,
@fecha_pago,
@fecha_baja,
@procesado
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
update ChequesBCRA
set visible = 0,
modified = getdate()
where ChequesBCRA.cuit_firmante = @cuit_firmante
AND isnull(ChequesBCRA.cuit_relacionado,'') = isnull(@Cuit_relacionado,'')
AND ChequesBCRA.nro_cheque = @nro_cheque
AND ChequesBCRA.importe = @importe
AND ChequesBCRA.fecha_rechazo = @fecha_rechazo
update ChequesBCRA_bajas
set procesado = 'S'
where id_cheque = @id_cheque
-- wait for 1 second
WAITFOR DELAY '00:00:00.200'
Fetch next from bn INTO
@id_cheque,
@cuit_firmante,
@cuit_relacionado,
@nro_cheque,
@fecha_rechazo,
@importe,
@id_causa,
@fecha_levantamiento,
@fecha_pago,
@fecha_baja,
@procesado
END
CLOSE bn
DEALLOCATE bn
/*
WAITFOR DELAY '00:00:00.100'
*/
delete CHEQ_RECH_BAJAS_20180214
delete chequesbajas2020 where procesado = 1
delete chequesBCRA_txt_bajas where procesado = 1
insert into ChequesBCRA (cuit_firmante, nro_cheque, fecha_rechazo, importe, id_causa, fecha_levantamiento, fecha_pago,
cuit_relacionado, visible, en_revision, multa_no_aplica, suspendido,created, usuarioifx, idifx)
SELECT cuit_firmante, nro_cheque, fecha_rechazo, importe, id_causa, fecha_levantamiento, fecha_pago,
cuit_relacionado, visible, en_revision, multa_no_aplica, suspendido,getdate() as created, usuarioifx, idifx
FROM CHEQ_RECH_20180214
delete CHEQ_RECH_20180214
/* Insertamos las altas
declare @id_chequeA int,
@cuit_firmanteA varchar(11),
@cuit_relacionadoA varchar(11) ,
@nro_chequeA int ,
@fecha_rechazoA smalldatetime ,
@importeA money ,
@id_causaA smallint ,
@fecha_levantamientoA smalldatetime ,
@fecha_pagoA smalldatetime ,
@fecha_bajaA date ,
@procesadoA char(1) ,
@visibleA bit,
@en_revisionA tinyint,
@multa_no_aplicaA tinyint,
@suspendidoA tinyint,
@createdA datetime,
@usuarioifxA varchar(10),
@idifxA int
DECLARE altacheques CURSOR FOR
select id_cheque,cuit_firmante,cuit_relacionado,nro_cheque,fecha_rechazo,importe,id_causa,fecha_levantamiento,fecha_pago,
visible,en_revision,multa_no_aplica,suspendido,created,usuarioifx,idifx from CHEQ_RECH_20180214
OPEN altacheques
Fetch next from altacheques INTO
@id_chequeA,
@cuit_firmanteA,
@cuit_relacionadoA,
@nro_chequeA,
@fecha_rechazoA,
@importeA,
@id_causaA,
@fecha_levantamientoA,
@fecha_pagoA,
@visibleA,
@en_revisionA,
@multa_no_aplicaA,
@suspendidoA,
@createdA,
@usuarioifxA,
@idifxA
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
set @createdA = getdate()
insert into ChequesBCRA (cuit_firmante,cuit_relacionado,nro_cheque,fecha_rechazo,importe,id_causa,fecha_levantamiento,fecha_pago,
visible,en_revision,multa_no_aplica,suspendido,created,usuarioifx,idifx)
values (@cuit_firmanteA,
@cuit_relacionadoA,
@nro_chequeA,
@fecha_rechazoA,
@importeA,
@id_causaA,
@fecha_levantamientoA,
@fecha_pagoA,
@visibleA,
@en_revisionA,
@multa_no_aplicaA,
@suspendidoA,
@createdA,
@usuarioifxA,
@idifxA)
-- wait for 1 second
/*
WAITFOR DELAY '00:00:01'
*/
WAITFOR DELAY '00:00:00.010'
delete CHEQ_RECH_20180214 where id_cheque = @id_chequeA
Fetch next from altacheques INTO
@id_chequeA,
@cuit_firmanteA,
@cuit_relacionadoA,
@nro_chequeA,
@fecha_rechazoA,
@importeA,
@id_causaA,
@fecha_levantamientoA,
@fecha_pagoA,
@visibleA,
@en_revisionA,
@multa_no_aplicaA,
@suspendidoA,
@createdA,
@usuarioifxA,
@idifxA
END
CLOSE altacheques
DEALLOCATE altacheques
*/
END
GO