Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
6| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_id_balance | int | 4 | |
| @p_contraparte | int | 4 | |
| @p_fecha_balance | date | 3 | |
| @p_periodo | smallint | 2 | |
| @p_ejercicio | int | 4 | |
| @p_moneda | varchar | 3 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.LN_balances_alta
-- Add the parameters for the stored procedure here
@p_id_balance int,
@p_contraparte int,
@p_fecha_balance date,
@p_periodo smallint,
@p_ejercicio int,
@p_moneda varchar(3)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @moneda varchar(3) = @p_moneda
declare @balance int
if(@p_moneda is null) begin
select @moneda = monedas.moneda
from LN_contrapartes inner join padrones on LN_contrapartes.id_padron = padrones.id_padron
inner join identificadores on padrones.identificador = identificadores.identificador
inner join monedas on identificadores.country_code = monedas.country_code
where LN_contrapartes.contraparte = @p_contraparte
end
if not exists (select balance from LN_balance
where contraparte = @p_contraparte
and fecha_balance = @p_fecha_balance) begin
insert into LN_balance
(id_balance, contraparte, fecha_balance, periodo, ejercicio, moneda, estado_balance, created)
values
(@p_id_balance, @p_contraparte, @p_fecha_balance, @p_periodo, @p_ejercicio, @moneda, 'P', GETDATE())
set @balance = SCOPE_IDENTITY()
SELECT @balance AS balance
end
END
GO
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.LN_balances_alta
-- Add the parameters for the stored procedure here
@p_id_balance int,
@p_contraparte int,
@p_fecha_balance date,
@p_periodo smallint,
@p_ejercicio int,
@p_moneda varchar(3)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @moneda varchar(3) = @p_moneda
declare @balance int
if(@p_moneda is null) begin
select @moneda = monedas.moneda
from LN_contrapartes inner join padrones on LN_contrapartes.id_padron = padrones.id_padron
inner join identificadores on padrones.identificador = identificadores.identificador
inner join monedas on identificadores.country_code = monedas.country_code
where LN_contrapartes.contraparte = @p_contraparte
end
if not exists (select balance from LN_balance
where contraparte = @p_contraparte
and fecha_balance = @p_fecha_balance) begin
insert into LN_balance
(id_balance, contraparte, fecha_balance, periodo, ejercicio, moneda, estado_balance, created)
values
(@p_id_balance, @p_contraparte, @p_fecha_balance, @p_periodo, @p_ejercicio, @moneda, 'P', GETDATE())
set @balance = SCOPE_IDENTITY()
SELECT @balance AS balance
end
END
GO
Used By
No items found