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 | |
| @relacion_1 | int | 4 | |
| @nombre_2 | varchar | 60 | |
| @ident_2 | varchar | 20 | |
| @numero_2 | varchar | 40 | |
| @relacion_2 | int | 4 | |
| @nombre_3 | varchar | 60 | |
| @ident_3 | varchar | 20 | |
| @numero_3 | varchar | 40 | |
| @relacion_3 | int | 4 | |
| @nombre_4 | varchar | 60 | |
| @ident_4 | varchar | 20 | |
| @numero_4 | varchar | 40 | |
| @relacion_4 | int | 4 | |
| @nombre_5 | varchar | 60 | |
| @ident_5 | varchar | 20 | |
| @numero_5 | varchar | 40 | |
| @relacion_5 | int | 4 | |
| @nombre_6 | varchar | 60 | |
| @ident_6 | varchar | 20 | |
| @numero_6 | varchar | 40 | |
| @relacion_6 | int | 4 | |
| @nombre_7 | varchar | 60 | |
| @ident_7 | varchar | 20 | |
| @numero_7 | varchar | 40 | |
| @relacion_7 | int | 4 | |
| @nombre_8 | varchar | 60 | |
| @ident_8 | varchar | 20 | |
| @numero_8 | varchar | 40 | |
| @relacion_8 | int | 4 | |
| @nombre_9 | varchar | 60 | |
| @ident_9 | varchar | 20 | |
| @numero_9 | varchar | 40 | |
| @relacion_9 | int | 4 | |
| @nombre_10 | varchar | 60 | |
| @ident_10 | varchar | 20 | |
| @numero_10 | varchar | 40 | |
| @relacion_10 | int | 4 |
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_vinculacion
-- 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,
@relacion_1 int = NULL,
@nombre_2 varchar(60) = NULL,
@ident_2 varchar(20) = NULL,
@numero_2 varchar(40) = NULL,
@relacion_2 int = NULL,
@nombre_3 varchar(60) = NULL,
@ident_3 varchar(20) = NULL,
@numero_3 varchar(40) = NULL,
@relacion_3 int = NULL,
@nombre_4 varchar(60) = NULL,
@ident_4 varchar(20) = NULL,
@numero_4 varchar(40) = NULL,
@relacion_4 int = NULL,
@nombre_5 varchar(60) = NULL,
@ident_5 varchar(20) = NULL,
@numero_5 varchar(40) = NULL,
@relacion_5 int = NULL,
@nombre_6 varchar(60) = NULL,
@ident_6 varchar(20) = NULL,
@numero_6 varchar(40) = NULL,
@relacion_6 int = NULL,
@nombre_7 varchar(60) = NULL,
@ident_7 varchar(20) = NULL,
@numero_7 varchar(40) = NULL,
@relacion_7 int = NULL,
@nombre_8 varchar(60) = NULL,
@ident_8 varchar(20) = NULL,
@numero_8 varchar(40) = NULL,
@relacion_8 int = NULL,
@nombre_9 varchar(60) = NULL,
@ident_9 varchar(20) = NULL,
@numero_9 varchar(40) = NULL,
@relacion_9 int = NULL,
@nombre_10 varchar(60) = NULL,
@ident_10 varchar(20) = NULL,
@numero_10 varchar(40) = NULL,
@relacion_10 int = 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
declare @id_padron int = NULL
if (@contraparte > 0 AND @doc_id > 0) begin
select @cuit = padrones.identificacion, @id_padron = padrones.id_padron
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) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_1)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_1, @relacion_1, 1, @id_padron, @d1, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d1, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_1
end
if (@d2 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_2)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_2, @relacion_2, 1, @id_padron, @d2, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d2, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_2
end
if (@d3 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_3)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_3, @relacion_3, 1, @id_padron, @d3, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d3, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_3
end
if (@d4 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_4)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_4, @relacion_4, 1, @id_padron, @d4, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d4, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_4
end
if (@d5 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_5)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_5, @relacion_5, 1, @id_padron, @d5, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d5, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_5
end
if (@d6 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_6)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_6, @relacion_6, 1, @id_padron, @d6, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d6, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_6
end
if (@d7 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_7)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_7, @relacion_7, 1, @id_padron, @d7, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d7, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_7
end
if (@d8 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_8)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_8, @relacion_8, 1, @id_padron, @d8, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d8, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_8
end
if (@d9 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_9)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_9, @relacion_9, 1, @id_padron, @d9, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d9, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_9
end
if (@d10 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_10)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_10, @relacion_10, 1, @id_padron, @d10, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d10, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_10
end
end
end
END
GO
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.LN_doc_actualizar_vinculacion
-- 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,
@relacion_1 int = NULL,
@nombre_2 varchar(60) = NULL,
@ident_2 varchar(20) = NULL,
@numero_2 varchar(40) = NULL,
@relacion_2 int = NULL,
@nombre_3 varchar(60) = NULL,
@ident_3 varchar(20) = NULL,
@numero_3 varchar(40) = NULL,
@relacion_3 int = NULL,
@nombre_4 varchar(60) = NULL,
@ident_4 varchar(20) = NULL,
@numero_4 varchar(40) = NULL,
@relacion_4 int = NULL,
@nombre_5 varchar(60) = NULL,
@ident_5 varchar(20) = NULL,
@numero_5 varchar(40) = NULL,
@relacion_5 int = NULL,
@nombre_6 varchar(60) = NULL,
@ident_6 varchar(20) = NULL,
@numero_6 varchar(40) = NULL,
@relacion_6 int = NULL,
@nombre_7 varchar(60) = NULL,
@ident_7 varchar(20) = NULL,
@numero_7 varchar(40) = NULL,
@relacion_7 int = NULL,
@nombre_8 varchar(60) = NULL,
@ident_8 varchar(20) = NULL,
@numero_8 varchar(40) = NULL,
@relacion_8 int = NULL,
@nombre_9 varchar(60) = NULL,
@ident_9 varchar(20) = NULL,
@numero_9 varchar(40) = NULL,
@relacion_9 int = NULL,
@nombre_10 varchar(60) = NULL,
@ident_10 varchar(20) = NULL,
@numero_10 varchar(40) = NULL,
@relacion_10 int = 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
declare @id_padron int = NULL
if (@contraparte > 0 AND @doc_id > 0) begin
select @cuit = padrones.identificacion, @id_padron = padrones.id_padron
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) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_1)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_1, @relacion_1, 1, @id_padron, @d1, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d1, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_1
end
if (@d2 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_2)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_2, @relacion_2, 1, @id_padron, @d2, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d2, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_2
end
if (@d3 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_3)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_3, @relacion_3, 1, @id_padron, @d3, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d3, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_3
end
if (@d4 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_4)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_4, @relacion_4, 1, @id_padron, @d4, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d4, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_4
end
if (@d5 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_5)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_5, @relacion_5, 1, @id_padron, @d5, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d5, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_5
end
if (@d6 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_6)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_6, @relacion_6, 1, @id_padron, @d6, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d6, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_6
end
if (@d7 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_7)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_7, @relacion_7, 1, @id_padron, @d7, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d7, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_7
end
if (@d8 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_8)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_8, @relacion_8, 1, @id_padron, @d8, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d8, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_8
end
if (@d9 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_9)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_9, @relacion_9, 1, @id_padron, @d9, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d9, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_9
end
if (@d10 > 0) begin
if not exists (select cod_vinculacion from vinculaciones where cuit_sociedad = @cuit and cuit_vinculada = @numero_10)
insert into vinculaciones
(cuit_sociedad, cuit_vinculada, cod_vinculacion, visible, id_padron_sociedad, id_padron_vinculada, created)
values
(@cuit, @numero_10, @relacion_10, 1, @id_padron, @d10, GETDATE())
else
update vinculaciones set visible = 1, id_padron_sociedad = @cuit, id_padron_vinculada = @d10, modified = GETDATE()
where cuit_sociedad = @cuit and cuit_vinculada = @numero_10
end
end
end
END
GO
Used By
No items found