Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
5| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_cuit | varchar | 13 | |
| @id_usuario | int | 4 | |
| @id_cliente | int | 4 | |
| @seccion | varchar | 100 | |
| @fecha_vigencia | date | 3 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
update monitoreos set visible = 1 where cuit = '27208925658' and cliente = 515494256
select * from trazabilidad_monitoreos
insert into monitoreos (cliente, user_id, seccion_mantenimiento, fecha_vigencia_mantenimiento, visible, cuit, created)
values (2254875, 94437923, '10','2099-12-31',1,'27208925658',getdate())
exec [eliminar_monitoreo] '27208925658', 1, 515494256, '0',null
*/
CREATE OR ALTER PROCEDURE dbo.eliminar_monitoreo
@p_cuit varchar(13),
@id_usuario int,
@id_cliente int,
@seccion varchar(100),
@fecha_vigencia date = null
AS
BEGIN
SET NOCOUNT ON;
/* 06/02/2025: Nuevo sistema de Monitoreo, se decidió:
Se pasa como no visible, los registros de todos los usuarios sin importar si son propios
que aun estén vigentes (no haya llegado a la fecha de fin)
y se pone como fecha de fin de monitoreo, ahora (salvo que ya este vencido, que no debería pasar, porque si te aparece para inactivar es porque esta vigente)
*/
-- Si seccion es un numero, solo esa seccion de ese CUIT / Cliente
-- Si seccion = 0, borra todas las secciones de ese CUIT / Cliente
-- Si es una lista separada por comas, toda esa lista de secciones de ese CUIT / Cliente
update monitoreos
set monitoreos.visible = 0,
fecha_vigencia_mantenimiento = iif(fecha_vigencia_mantenimiento>getdate(),getdate(),fecha_vigencia_mantenimiento),
fecha_modificacion = GETDATE(),
modificado_por = @id_usuario
where cliente = @id_cliente
and cuit = @p_cuit
and (seccion_mantenimiento = @seccion
or @seccion = '0'
or seccion_mantenimiento in (select item from dbo.DelimitedSplit8K(@seccion,',')))
and fecha_vigencia_mantenimiento >= getdate()
and visible = 1
/*
update monitoreos set monitoreos.visible = 0
where user_id = @id_usuario AND cliente = @id_cliente and cuit = @p_cuit and seccion_mantenimiento = @seccion and visible = 1
*/
/*delete monitoreos
where user_id = @id_usuario
AND cliente = @id_cliente
and cuit = @p_cuit
and seccion_mantenimiento = @seccion
and visible = 1*/
END
GO
GO
/*
update monitoreos set visible = 1 where cuit = '27208925658' and cliente = 515494256
select * from trazabilidad_monitoreos
insert into monitoreos (cliente, user_id, seccion_mantenimiento, fecha_vigencia_mantenimiento, visible, cuit, created)
values (2254875, 94437923, '10','2099-12-31',1,'27208925658',getdate())
exec [eliminar_monitoreo] '27208925658', 1, 515494256, '0',null
*/
CREATE OR ALTER PROCEDURE dbo.eliminar_monitoreo
@p_cuit varchar(13),
@id_usuario int,
@id_cliente int,
@seccion varchar(100),
@fecha_vigencia date = null
AS
BEGIN
SET NOCOUNT ON;
/* 06/02/2025: Nuevo sistema de Monitoreo, se decidió:
Se pasa como no visible, los registros de todos los usuarios sin importar si son propios
que aun estén vigentes (no haya llegado a la fecha de fin)
y se pone como fecha de fin de monitoreo, ahora (salvo que ya este vencido, que no debería pasar, porque si te aparece para inactivar es porque esta vigente)
*/
-- Si seccion es un numero, solo esa seccion de ese CUIT / Cliente
-- Si seccion = 0, borra todas las secciones de ese CUIT / Cliente
-- Si es una lista separada por comas, toda esa lista de secciones de ese CUIT / Cliente
update monitoreos
set monitoreos.visible = 0,
fecha_vigencia_mantenimiento = iif(fecha_vigencia_mantenimiento>getdate(),getdate(),fecha_vigencia_mantenimiento),
fecha_modificacion = GETDATE(),
modificado_por = @id_usuario
where cliente = @id_cliente
and cuit = @p_cuit
and (seccion_mantenimiento = @seccion
or @seccion = '0'
or seccion_mantenimiento in (select item from dbo.DelimitedSplit8K(@seccion,',')))
and fecha_vigencia_mantenimiento >= getdate()
and visible = 1
/*
update monitoreos set monitoreos.visible = 0
where user_id = @id_usuario AND cliente = @id_cliente and cuit = @p_cuit and seccion_mantenimiento = @seccion and visible = 1
*/
/*delete monitoreos
where user_id = @id_usuario
AND cliente = @id_cliente
and cuit = @p_cuit
and seccion_mantenimiento = @seccion
and visible = 1*/
END
GO
Depends On
2Used By
No items found