Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
4| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_cliente | int | 4 | |
| @p_activo | char | 1 | |
| @p_usuario | int | 4 | |
| @agrupamiento | bit | 1 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
[backend_activar_desactivar_clientes] 8558396,'N',94437923
select estado_cliente, * from clientes where cliente = 8558396
update clientes set estado_cliente = 'Y' where cliente = 8558396
*/
CREATE OR ALTER PROCEDURE dbo.backend_activar_desactivar_clientes
@p_cliente int ,
@p_activo char(1),
@p_usuario int,
@agrupamiento bit = 0
AS
BEGIN
SET NOCOUNT ON;
declare @cliente_agrupado int
update clientes
set estado_cliente = @p_activo,
modified = GETDATE(),
modified_by = @p_usuario
where clientes.cliente = @p_cliente
-- Si puso inactivo el cliente, inactiva todos los logines y todos los productos
if (@p_activo = 'N')
begin
update users
set active_user = 'N'
where user_id in (select user_id from usuarios_productos where cliente = @p_cliente)
update clientes_productos
set activo = 0,
modified = GETDATE(),
modified_by = @p_usuario
where cliente = @p_cliente
update usuarios_productos
set activo = 0,
modified = GETDATE(),
modified_by = @p_usuario
where cliente = @p_cliente
-- 03/01/2025: Busca todos los clientes agrupados y los inactiva a esos clientes / productos / logines
DECLARE C_clientes CURSOR FOR
select cliente
from clientes_union
where cliente_union = @p_cliente
OPEN C_clientes
FETCH NEXT FROM C_clientes INTO @cliente_agrupado
WHILE @@fetch_status = 0
BEGIN
exec [backend_activar_desactivar_clientes] @cliente_agrupado,@p_activo,@p_usuario,1
FETCH NEXT FROM C_clientes INTO @cliente_agrupado
END
CLOSE C_clientes
DEALLOCATE C_clientes
end
if @agrupamiento = 0
begin
select '0' as error, 'Modificación OK' as mensaje
end
END
/*
select estado_cliente, * from clientes where cliente in (
select cliente from clientes_union where cliente_union = 8558396)
*/
GO
GO
/*
[backend_activar_desactivar_clientes] 8558396,'N',94437923
select estado_cliente, * from clientes where cliente = 8558396
update clientes set estado_cliente = 'Y' where cliente = 8558396
*/
CREATE OR ALTER PROCEDURE dbo.backend_activar_desactivar_clientes
@p_cliente int ,
@p_activo char(1),
@p_usuario int,
@agrupamiento bit = 0
AS
BEGIN
SET NOCOUNT ON;
declare @cliente_agrupado int
update clientes
set estado_cliente = @p_activo,
modified = GETDATE(),
modified_by = @p_usuario
where clientes.cliente = @p_cliente
-- Si puso inactivo el cliente, inactiva todos los logines y todos los productos
if (@p_activo = 'N')
begin
update users
set active_user = 'N'
where user_id in (select user_id from usuarios_productos where cliente = @p_cliente)
update clientes_productos
set activo = 0,
modified = GETDATE(),
modified_by = @p_usuario
where cliente = @p_cliente
update usuarios_productos
set activo = 0,
modified = GETDATE(),
modified_by = @p_usuario
where cliente = @p_cliente
-- 03/01/2025: Busca todos los clientes agrupados y los inactiva a esos clientes / productos / logines
DECLARE C_clientes CURSOR FOR
select cliente
from clientes_union
where cliente_union = @p_cliente
OPEN C_clientes
FETCH NEXT FROM C_clientes INTO @cliente_agrupado
WHILE @@fetch_status = 0
BEGIN
exec [backend_activar_desactivar_clientes] @cliente_agrupado,@p_activo,@p_usuario,1
FETCH NEXT FROM C_clientes INTO @cliente_agrupado
END
CLOSE C_clientes
DEALLOCATE C_clientes
end
if @agrupamiento = 0
begin
select '0' as error, 'Modificación OK' as mensaje
end
END
/*
select estado_cliente, * from clientes where cliente in (
select cliente from clientes_union where cliente_union = 8558396)
*/
GO
Depends On
5Used By
No items found