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
-- update juicios_borrar_cuit set procesado = null
-- exec sp_juicios_borrar_cuit
CREATE OR ALTER PROCEDURE dbo.sp_juicios_borrar_cuit
AS
BEGIN
SET NOCOUNT ON;
declare @cant int = 0,
@procesados int = 0,
@no_procesados int = 0,
@idifx varchar(50),
@cuit_demandado varchar(20),
@id_tipo_causa varchar(10),
@fecha_causa date,
@juzgado varchar(50),
@secretaria varchar(50),
@fuente varchar(10),
@fecha_fuente date,
@procesado bit,
@id_jbc int
DECLARE recorre CURSOR FOR
select top 10000 * from juicios_borrar_cuit
where procesado is null
OPEN recorre
Fetch next from recorre INTO @idifx ,
@cuit_demandado,
@id_tipo_causa,
@fecha_causa,
@juzgado,
@secretaria,
@fuente,
@fecha_fuente,
@procesado,
@id_jbc
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
set @cant = (
select count(*)
from juicios
where cuit_demandado = @cuit_demandado
and id_tipo_causa = @id_tipo_causa
and fecha_causa = @fecha_causa
and fuente = @fuente
and fecha_fuente = @fecha_fuente
and juzgado = @juzgado
and secretaria = @secretaria
)
if (@cant > 0)
begin
update juicios set cuit_demandado_borrado = cuit_demandado, cuit_demandado = null
where cuit_demandado = @cuit_demandado
and id_tipo_causa = @id_tipo_causa
and fecha_causa = @fecha_causa
and fuente = @fuente
and fecha_fuente = @fecha_fuente
and juzgado = @juzgado
and secretaria = @secretaria
update juicios_borrar_cuit
set procesado = 1
where id_jbc = @id_jbc
set @procesados = @procesados + 1
end
else
begin
update juicios_borrar_cuit
set procesado = 0
where id_jbc = @id_jbc
set @no_procesados = @no_procesados + 1
end
Fetch next from recorre INTO @idifx ,
@cuit_demandado,
@id_tipo_causa,
@fecha_causa,
@juzgado,
@secretaria,
@fuente,
@fecha_fuente,
@procesado,
@id_jbc
END
CLOSE recorre
DEALLOCATE recorre
select @procesados as procesados, @no_procesados as no_procesados
END
GO
GO
-- update juicios_borrar_cuit set procesado = null
-- exec sp_juicios_borrar_cuit
CREATE OR ALTER PROCEDURE dbo.sp_juicios_borrar_cuit
AS
BEGIN
SET NOCOUNT ON;
declare @cant int = 0,
@procesados int = 0,
@no_procesados int = 0,
@idifx varchar(50),
@cuit_demandado varchar(20),
@id_tipo_causa varchar(10),
@fecha_causa date,
@juzgado varchar(50),
@secretaria varchar(50),
@fuente varchar(10),
@fecha_fuente date,
@procesado bit,
@id_jbc int
DECLARE recorre CURSOR FOR
select top 10000 * from juicios_borrar_cuit
where procesado is null
OPEN recorre
Fetch next from recorre INTO @idifx ,
@cuit_demandado,
@id_tipo_causa,
@fecha_causa,
@juzgado,
@secretaria,
@fuente,
@fecha_fuente,
@procesado,
@id_jbc
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
set @cant = (
select count(*)
from juicios
where cuit_demandado = @cuit_demandado
and id_tipo_causa = @id_tipo_causa
and fecha_causa = @fecha_causa
and fuente = @fuente
and fecha_fuente = @fecha_fuente
and juzgado = @juzgado
and secretaria = @secretaria
)
if (@cant > 0)
begin
update juicios set cuit_demandado_borrado = cuit_demandado, cuit_demandado = null
where cuit_demandado = @cuit_demandado
and id_tipo_causa = @id_tipo_causa
and fecha_causa = @fecha_causa
and fuente = @fuente
and fecha_fuente = @fecha_fuente
and juzgado = @juzgado
and secretaria = @secretaria
update juicios_borrar_cuit
set procesado = 1
where id_jbc = @id_jbc
set @procesados = @procesados + 1
end
else
begin
update juicios_borrar_cuit
set procesado = 0
where id_jbc = @id_jbc
set @no_procesados = @no_procesados + 1
end
Fetch next from recorre INTO @idifx ,
@cuit_demandado,
@id_tipo_causa,
@fecha_causa,
@juzgado,
@secretaria,
@fuente,
@fecha_fuente,
@procesado,
@id_jbc
END
CLOSE recorre
DEALLOCATE recorre
select @procesados as procesados, @no_procesados as no_procesados
END
GO
Depends On
2Used By
No items found