dbo.LN_contrapartes_PP

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

6
Name Data Type Length Description
@accion varchar 20
@contraparte int 4
@fecha date 3
@monto float 8
@moneda varchar 10
@id int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
exec [LN_contrapartes_DE_LCS] 'MLCS','delete', 31319,null,null,null,null,null,null,null,6621 
select * from LN_contrapartes_queue where processed = 0
*/

CREATE OR ALTER PROCEDURE dbo.LN_contrapartes_PP 
 @accion      varchar(20),
 @contraparte int,
 @fecha date = null, 
 @monto float = null, 
 @moneda varchar(10) = null, 
 @id int = null
AS
BEGIN
 SET NOCOUNT ON;

 if (@accion = 'select')
 begin 
  select distinct contraparte, monto as monto, fecha, convert(varchar,fecha,103) as fecha_dmy, 
      moneda, visible, id 
  from LN_contraparte_plan_pagos 
  where contraparte = @contraparte --and visible = 1 
  order by fecha desc
 end 

 if (@accion = 'delete')
 begin 
  update LN_contraparte_plan_pagos  
  set visible = iif(visible = 0, 1, 0), 
   modified = getdate()
  where id = @id 
 end 

 if (@accion = 'insert')
 begin 
  insert into LN_contraparte_plan_pagos  (contraparte, fecha, monto, moneda, visible) 
  values (@contraparte, @fecha, @monto, @moneda, 1)
 end 
 
  if (@accion = 'insert' or @accion = 'delete')
  begin
     if not exists (select * from LN_contrapartes_queue where contraparte = @contraparte and processed = 0)
   insert into LN_contrapartes_queue(contraparte) values (@contraparte)
  end

END 

GO

Used By

No items found