Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
8| Name | Data Type | Length | Description |
|---|---|---|---|
| @accion | varchar | 500 | |
| @cliente | int | 4 | |
| @id_producto | int | 4 | |
| @nombre | varchar | 200 | |
| @moneda | varchar | 3 | |
| @country_code | varchar | 2 | |
| @valor | decimal | 9 | |
| @user_id | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Leonel Turchetto>
-- Create date: <24 de Octubre de 2019>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.mp_productos
@accion varchar(500),
@cliente int,
@id_producto int,
@nombre varchar(200),
@moneda varchar(3),
@country_code varchar(2),
@valor decimal(18,2),
@user_id int
AS
BEGIN
SET NOCOUNT ON;
if(@accion = 'obtener_productos_activos')
begin
select nombre,moneda,iif(mcpp.valor is not null,mcpp.valor,mcp.valor) as valor from mp_clientes_productos mcp
left join mp_clientes_productos_personalizado mcpp
on mcpp.id_mp_productos = mcp.id_mp_productos where activo = 1 and cliente= @cliente and id_producto = @id_producto
end
if(@accion = 'insertar_producto')
begin
insert into mp_clientes_productos
(cliente,id_producto,nombre,valor,moneda,country_code,created_by)
values
(@cliente,@id_producto,@nombre,@valor,@moneda,@country_code,@user_id)
end
if(@accion = 'actualizar_producto_activo')
begin
update mp_clientes_productos set nombre = @nombre,moneda = @moneda,valor = @valor,modified=getdate(),modified_by=@user_id where id_producto = @id_producto
end
END
GO
GO
-- =============================================
-- Author: <Leonel Turchetto>
-- Create date: <24 de Octubre de 2019>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.mp_productos
@accion varchar(500),
@cliente int,
@id_producto int,
@nombre varchar(200),
@moneda varchar(3),
@country_code varchar(2),
@valor decimal(18,2),
@user_id int
AS
BEGIN
SET NOCOUNT ON;
if(@accion = 'obtener_productos_activos')
begin
select nombre,moneda,iif(mcpp.valor is not null,mcpp.valor,mcp.valor) as valor from mp_clientes_productos mcp
left join mp_clientes_productos_personalizado mcpp
on mcpp.id_mp_productos = mcp.id_mp_productos where activo = 1 and cliente= @cliente and id_producto = @id_producto
end
if(@accion = 'insertar_producto')
begin
insert into mp_clientes_productos
(cliente,id_producto,nombre,valor,moneda,country_code,created_by)
values
(@cliente,@id_producto,@nombre,@valor,@moneda,@country_code,@user_id)
end
if(@accion = 'actualizar_producto_activo')
begin
update mp_clientes_productos set nombre = @nombre,moneda = @moneda,valor = @valor,modified=getdate(),modified_by=@user_id where id_producto = @id_producto
end
END
GO
Depends On
No items found