Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
42| Name | Data Type | Length | Description |
|---|---|---|---|
| @contraparte | int | 4 | |
| @doc_id | int | 4 | |
| @nombre_1 | varchar | 60 | |
| @ident_1 | varchar | 20 | |
| @numero_1 | varchar | 40 | |
| @porcentaje_1 | float | 8 | |
| @nombre_2 | varchar | 60 | |
| @ident_2 | varchar | 20 | |
| @numero_2 | varchar | 40 | |
| @porcentaje_2 | float | 8 | |
| @nombre_3 | varchar | 60 | |
| @ident_3 | varchar | 20 | |
| @numero_3 | varchar | 40 | |
| @porcentaje_3 | float | 8 | |
| @nombre_4 | varchar | 60 | |
| @ident_4 | varchar | 20 | |
| @numero_4 | varchar | 40 | |
| @porcentaje_4 | float | 8 | |
| @nombre_5 | varchar | 60 | |
| @ident_5 | varchar | 20 | |
| @numero_5 | varchar | 40 | |
| @porcentaje_5 | float | 8 | |
| @nombre_6 | varchar | 60 | |
| @ident_6 | varchar | 20 | |
| @numero_6 | varchar | 40 | |
| @porcentaje_6 | float | 8 | |
| @nombre_7 | varchar | 60 | |
| @ident_7 | varchar | 20 | |
| @numero_7 | varchar | 40 | |
| @porcentaje_7 | float | 8 | |
| @nombre_8 | varchar | 60 | |
| @ident_8 | varchar | 20 | |
| @numero_8 | varchar | 40 | |
| @porcentaje_8 | float | 8 | |
| @nombre_9 | varchar | 60 | |
| @ident_9 | varchar | 20 | |
| @numero_9 | varchar | 40 | |
| @porcentaje_9 | float | 8 | |
| @nombre_10 | varchar | 60 | |
| @ident_10 | varchar | 20 | |
| @numero_10 | varchar | 40 | |
| @porcentaje_10 | float | 8 |
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_doc_actualizar_socios
-- Add the parameters for the stored procedure here
@contraparte int = NULL,
@doc_id int = NULL,
@nombre_1 varchar(60) = NULL,
@ident_1 varchar(20) = NULL,
@numero_1 varchar(40) = NULL,
@porcentaje_1 float = NULL,
@nombre_2 varchar(60) = NULL,
@ident_2 varchar(20) = NULL,
@numero_2 varchar(40) = NULL,
@porcentaje_2 float = NULL,
@nombre_3 varchar(60) = NULL,
@ident_3 varchar(20) = NULL,
@numero_3 varchar(40) = NULL,
@porcentaje_3 float = NULL,
@nombre_4 varchar(60) = NULL,
@ident_4 varchar(20) = NULL,
@numero_4 varchar(40) = NULL,
@porcentaje_4 float = NULL,
@nombre_5 varchar(60) = NULL,
@ident_5 varchar(20) = NULL,
@numero_5 varchar(40) = NULL,
@porcentaje_5 float = NULL,
@nombre_6 varchar(60) = NULL,
@ident_6 varchar(20) = NULL,
@numero_6 varchar(40) = NULL,
@porcentaje_6 float = NULL,
@nombre_7 varchar(60) = NULL,
@ident_7 varchar(20) = NULL,
@numero_7 varchar(40) = NULL,
@porcentaje_7 float = NULL,
@nombre_8 varchar(60) = NULL,
@ident_8 varchar(20) = NULL,
@numero_8 varchar(40) = NULL,
@porcentaje_8 float = NULL,
@nombre_9 varchar(60) = NULL,
@ident_9 varchar(20) = NULL,
@numero_9 varchar(40) = NULL,
@porcentaje_9 float = NULL,
@nombre_10 varchar(60) = NULL,
@ident_10 varchar(20) = NULL,
@numero_10 varchar(40) = NULL,
@porcentaje_10 float = NULL
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 @d1 int = 0
declare @d2 int = 0
declare @d3 int = 0
declare @d4 int = 0
declare @d5 int = 0
declare @d6 int = 0
declare @d7 int = 0
declare @d8 int = 0
declare @d9 int = 0
declare @d10 int = 0
declare @cuit varchar(30) = NULL
if (@contraparte > 0 AND @doc_id > 0) begin
select @cuit = padrones.identificacion from LN_contrapartes
inner join padrones on LN_contrapartes.id_padron = padrones.id_padron
where LN_contrapartes.contraparte = @contraparte
if (@nombre_1 is not null AND @numero_1 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_1
and numero = @numero_1) begin
exec backend_insertar_padron @ident_1, @numero_1, @nombre_1, 'F', 'M', 1
end
select @d1 = id_padron from padrones where identificador = @ident_1 and numero = @numero_1
end
if (@nombre_2 is not null AND @numero_2 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_2
and numero = @numero_2) begin
exec backend_insertar_padron @ident_2, @numero_2, @nombre_2, 'F', 'M', 1
end
select @d2 = id_padron from padrones where identificador = @ident_2 and numero = @numero_2
end
if (@nombre_3 is not null AND @numero_3 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_3
and numero = @numero_3) begin
exec backend_insertar_padron @ident_3, @numero_3, @nombre_3, 'F', 'M', 1
end
select @d3 = id_padron from padrones where identificador = @ident_3 and numero = @numero_3
end
if (@nombre_4 is not null AND @numero_4 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_4
and numero = @numero_4) begin
exec backend_insertar_padron @ident_4, @numero_4, @nombre_4, 'F', 'M', 1
end
select @d4 = id_padron from padrones where identificador = @ident_4 and numero = @numero_4
end
if (@nombre_5 is not null AND @numero_5 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_5
and numero = @numero_5) begin
exec backend_insertar_padron @ident_5, @numero_5, @nombre_5, 'F', 'M', 1
end
select @d5 = id_padron from padrones where identificador = @ident_5 and numero = @numero_5
end
if (@nombre_6 is not null AND @numero_6 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_6
and numero = @numero_6) begin
exec backend_insertar_padron @ident_6, @numero_6, @nombre_6, 'F', 'M', 1
end
select @d6 = id_padron from padrones where identificador = @ident_6 and numero = @numero_6
end
if (@nombre_7 is not null AND @numero_7 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_7
and numero = @numero_7) begin
exec backend_insertar_padron @ident_7, @numero_7, @nombre_7, 'F', 'M', 1
end
select @d7 = id_padron from padrones where identificador = @ident_7 and numero = @numero_7
end
if (@nombre_8 is not null AND @numero_8 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_8
and numero = @numero_8) begin
exec backend_insertar_padron @ident_8, @numero_8, @nombre_8, 'F', 'M', 1
end
select @d8 = id_padron from padrones where identificador = @ident_8 and numero = @numero_8
end
if (@nombre_9 is not null AND @numero_9 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_9
and numero = @numero_9) begin
exec backend_insertar_padron @ident_9, @numero_9, @nombre_9, 'F', 'M', 1
end
select @d9 = id_padron from padrones where identificador = @ident_9 and numero = @numero_9
end
if (@nombre_10 is not null AND @numero_10 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_10
and numero = @numero_10) begin
exec backend_insertar_padron @ident_10, @numero_10, @nombre_10, 'F', 'M', 1
end
select @d10 = id_padron from padrones where identificador = @ident_10 and numero = @numero_10
end
/*********************************************/
if (@d1 > 0 OR @d2 > 0 OR @d3 > 0 OR @d4 > 0 OR @d5 > 0 OR @d6 > 0 OR @d7 > 0 OR @d8 > 0 OR @d9 > 0 OR @d10 > 0) begin
if (@d1 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_1, format(@porcentaje_1, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d1, 1)
if (@d2 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_2, format(@porcentaje_2, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d2, 1)
if (@d3 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_3, format(@porcentaje_3, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d3, 1)
if (@d4 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_4, format(@porcentaje_4, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d4, 1)
if (@d5 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_5, format(@porcentaje_5, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d5, 1)
if (@d6 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_6, format(@porcentaje_6, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d6, 1)
if (@d7 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_7, format(@porcentaje_7, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d7, 1)
if (@d8 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_8, format(@porcentaje_8, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d8, 1)
if (@d9 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_9, format(@porcentaje_9, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d9, 1)
if (@d10 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_10, format(@porcentaje_10, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d10, 1)
end
end
END
GO
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.LN_doc_actualizar_socios
-- Add the parameters for the stored procedure here
@contraparte int = NULL,
@doc_id int = NULL,
@nombre_1 varchar(60) = NULL,
@ident_1 varchar(20) = NULL,
@numero_1 varchar(40) = NULL,
@porcentaje_1 float = NULL,
@nombre_2 varchar(60) = NULL,
@ident_2 varchar(20) = NULL,
@numero_2 varchar(40) = NULL,
@porcentaje_2 float = NULL,
@nombre_3 varchar(60) = NULL,
@ident_3 varchar(20) = NULL,
@numero_3 varchar(40) = NULL,
@porcentaje_3 float = NULL,
@nombre_4 varchar(60) = NULL,
@ident_4 varchar(20) = NULL,
@numero_4 varchar(40) = NULL,
@porcentaje_4 float = NULL,
@nombre_5 varchar(60) = NULL,
@ident_5 varchar(20) = NULL,
@numero_5 varchar(40) = NULL,
@porcentaje_5 float = NULL,
@nombre_6 varchar(60) = NULL,
@ident_6 varchar(20) = NULL,
@numero_6 varchar(40) = NULL,
@porcentaje_6 float = NULL,
@nombre_7 varchar(60) = NULL,
@ident_7 varchar(20) = NULL,
@numero_7 varchar(40) = NULL,
@porcentaje_7 float = NULL,
@nombre_8 varchar(60) = NULL,
@ident_8 varchar(20) = NULL,
@numero_8 varchar(40) = NULL,
@porcentaje_8 float = NULL,
@nombre_9 varchar(60) = NULL,
@ident_9 varchar(20) = NULL,
@numero_9 varchar(40) = NULL,
@porcentaje_9 float = NULL,
@nombre_10 varchar(60) = NULL,
@ident_10 varchar(20) = NULL,
@numero_10 varchar(40) = NULL,
@porcentaje_10 float = NULL
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 @d1 int = 0
declare @d2 int = 0
declare @d3 int = 0
declare @d4 int = 0
declare @d5 int = 0
declare @d6 int = 0
declare @d7 int = 0
declare @d8 int = 0
declare @d9 int = 0
declare @d10 int = 0
declare @cuit varchar(30) = NULL
if (@contraparte > 0 AND @doc_id > 0) begin
select @cuit = padrones.identificacion from LN_contrapartes
inner join padrones on LN_contrapartes.id_padron = padrones.id_padron
where LN_contrapartes.contraparte = @contraparte
if (@nombre_1 is not null AND @numero_1 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_1
and numero = @numero_1) begin
exec backend_insertar_padron @ident_1, @numero_1, @nombre_1, 'F', 'M', 1
end
select @d1 = id_padron from padrones where identificador = @ident_1 and numero = @numero_1
end
if (@nombre_2 is not null AND @numero_2 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_2
and numero = @numero_2) begin
exec backend_insertar_padron @ident_2, @numero_2, @nombre_2, 'F', 'M', 1
end
select @d2 = id_padron from padrones where identificador = @ident_2 and numero = @numero_2
end
if (@nombre_3 is not null AND @numero_3 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_3
and numero = @numero_3) begin
exec backend_insertar_padron @ident_3, @numero_3, @nombre_3, 'F', 'M', 1
end
select @d3 = id_padron from padrones where identificador = @ident_3 and numero = @numero_3
end
if (@nombre_4 is not null AND @numero_4 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_4
and numero = @numero_4) begin
exec backend_insertar_padron @ident_4, @numero_4, @nombre_4, 'F', 'M', 1
end
select @d4 = id_padron from padrones where identificador = @ident_4 and numero = @numero_4
end
if (@nombre_5 is not null AND @numero_5 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_5
and numero = @numero_5) begin
exec backend_insertar_padron @ident_5, @numero_5, @nombre_5, 'F', 'M', 1
end
select @d5 = id_padron from padrones where identificador = @ident_5 and numero = @numero_5
end
if (@nombre_6 is not null AND @numero_6 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_6
and numero = @numero_6) begin
exec backend_insertar_padron @ident_6, @numero_6, @nombre_6, 'F', 'M', 1
end
select @d6 = id_padron from padrones where identificador = @ident_6 and numero = @numero_6
end
if (@nombre_7 is not null AND @numero_7 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_7
and numero = @numero_7) begin
exec backend_insertar_padron @ident_7, @numero_7, @nombre_7, 'F', 'M', 1
end
select @d7 = id_padron from padrones where identificador = @ident_7 and numero = @numero_7
end
if (@nombre_8 is not null AND @numero_8 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_8
and numero = @numero_8) begin
exec backend_insertar_padron @ident_8, @numero_8, @nombre_8, 'F', 'M', 1
end
select @d8 = id_padron from padrones where identificador = @ident_8 and numero = @numero_8
end
if (@nombre_9 is not null AND @numero_9 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_9
and numero = @numero_9) begin
exec backend_insertar_padron @ident_9, @numero_9, @nombre_9, 'F', 'M', 1
end
select @d9 = id_padron from padrones where identificador = @ident_9 and numero = @numero_9
end
if (@nombre_10 is not null AND @numero_10 is not null) begin
if not exists (select id_padron
from padrones
where identificador = @ident_10
and numero = @numero_10) begin
exec backend_insertar_padron @ident_10, @numero_10, @nombre_10, 'F', 'M', 1
end
select @d10 = id_padron from padrones where identificador = @ident_10 and numero = @numero_10
end
/*********************************************/
if (@d1 > 0 OR @d2 > 0 OR @d3 > 0 OR @d4 > 0 OR @d5 > 0 OR @d6 > 0 OR @d7 > 0 OR @d8 > 0 OR @d9 > 0 OR @d10 > 0) begin
if (@d1 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_1, format(@porcentaje_1, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d1, 1)
if (@d2 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_2, format(@porcentaje_2, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d2, 1)
if (@d3 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_3, format(@porcentaje_3, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d3, 1)
if (@d4 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_4, format(@porcentaje_4, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d4, 1)
if (@d5 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_5, format(@porcentaje_5, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d5, 1)
if (@d6 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_6, format(@porcentaje_6, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d6, 1)
if (@d7 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_7, format(@porcentaje_7, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d7, 1)
if (@d8 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_8, format(@porcentaje_8, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d8, 1)
if (@d9 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_9, format(@porcentaje_9, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d9, 1)
if (@d10 > 0)
insert into socios
(c01_cuit, c01_cuit_soc, c04_porcentaje, c04_periodo_mes, c04_periodo_ano, c04_ultimo, c04_periodo_desde, created, id_padron, visible)
values
(@cuit, @numero_10, format(@porcentaje_10, '###.##'), NULL, NULL, 'S', NULL, GETDATE(), @d10, 1)
end
end
END
GO
Depends On
3Used By
No items found