Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
3| Name | Data Type | Length | Description |
|---|---|---|---|
| @cliente | int | 4 | |
| @familia | int | 4 | |
| @contraparte | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Turchetto,Leonel>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
-- [LN_obtener_score_personalizado] 5546348,27,352
CREATE OR ALTER PROCEDURE dbo.LN_obtener_score_personalizado-- 5546348,27,352
@cliente int,
@familia int,
@contraparte int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Declare a cursor for a Table or a View 'TableOrViewName' in schema 'dbo'
DECLARE @referencia varchar(50), @modalidad varchar(50), @tipo_doc int
DECLARE db_cursor CURSOR FOR
select referencia,modalidad,tipo_doc
from LN_score_referencias
where cliente = @cliente and familia = @familia order by modalidad desc
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @referencia, @modalidad, @tipo_doc
WHILE @@FETCH_STATUS = 0
BEGIN
declare @killer int,@killer_descripcion varchar(50)
declare @doc_id int
declare @estado_docs int
declare @cantidad_docs int
declare @campo char(1)
if(@modalidad = 'VERIFICACION')
begin
set @cantidad_docs =
(select count(doc_id)
from ln_docs
inner join LN_score_referencias on LN_score_referencias.cliente = ln_docs.cliente
where contraparte = @contraparte and ln_docs.tipo_doc = @tipo_doc and dependencia = 1 and aplica = 1 ) --and estado_doc = 'V'
set @estado_docs =
(select count(doc_id)
from ln_docs
inner join LN_score_referencias on LN_score_referencias.cliente = ln_docs.cliente
where contraparte = @contraparte and ln_docs.tipo_doc = @tipo_doc and dependencia = 1 and aplica = 1 and estado_doc = 'V')
select @cantidad_docs
if(@cantidad_docs != @estado_docs)
begin
set @killer = 1
set @killer_descripcion = @modalidad
end
-- set @doc_id = (select doc_id from LN_docs where cliente = @cliente and contraparte = @contraparte and tipo_doc = @tipo_doc)
-- select estado_doc from LN_docs where tipo_doc = @tipo_doc and contraparte = @contraparte and cliente = @cliente
end
--select * FROM LN_doc_campos
if(@modalidad = 'BUSCAR_CAMPO')
BEGIN
set @campo = (select tipo_campo from ln_tipo_doc_campos inner join LN_campos on LN_campos.campo = ln_tipo_doc_campos.campo where campo_id = @referencia)
set @doc_id = (select doc_id from LN_docs where cliente = @cliente and contraparte = @contraparte and tipo_doc = (select tipo_doc from LN_tipo_doc_campos where campo_id = @referencia))
select
case
when @campo = 'T' then valor_texto
when @campo = 'N' then valor_numerico
when @campo = 'D' then valor_fecha
when @campo ='B' then valor_numerico
when @campo ='S' then valor_texto
when @campo ='M' then valor_texto
when @campo ='R' then valor_numerico
when @campo ='C' then valor_numerico
when @campo ='F' then valor_texto
when @campo ='L' then valor_texto
when @campo ='G' then valor_texto
end
FROM LN_doc_campos where doc_id = @doc_id
-- select @doc_id
END
if(@killer = 1)
begin
select @killer_descripcion as killer_descripcion
BREAK;
end
-- [LN_obtener_score_personalizado] 5546348,27,352
FETCH NEXT FROM db_cursor INTO @referencia, @modalidad, @tipo_doc
END
CLOSE db_cursor
DEALLOCATE db_cursor
END
/*
select * from padrones where id_padron = 1003936
select * from LN_contrapartes where contraparte = 352
select doc_id from LN_docs where cliente = '5546348' and contraparte = 352 and tipo_doc = 1071
select * from LN_tipos_doc where tipo_doc = 1005
select top 100 * from LN_tipo_doc_campos where tipo_doc = 1071 order by campo_id
select * from LN_tipos_doc where tipo_doc = 1071
select top 100 * from LN_tipo_doc_campos where campo = 165 order by campo_id
select * from ln_doc_campos where campo = 165 and doc_id = 10122
--insert into LN_score_referencias (cliente,familia,referencia,modalidad) values (5546348,27,'AMX_CORRUPCION','BUSCAR_CAMPO')
--insert into LN_score_referencias (cliente,familia,tipo_doc,modalidad) values (5546348,27,1005,'VERIFICACION')
select * from LN_score_referencias where cliente = 5546348*/
GO
GO
-- =============================================
-- Author: <Turchetto,Leonel>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
-- [LN_obtener_score_personalizado] 5546348,27,352
CREATE OR ALTER PROCEDURE dbo.LN_obtener_score_personalizado-- 5546348,27,352
@cliente int,
@familia int,
@contraparte int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Declare a cursor for a Table or a View 'TableOrViewName' in schema 'dbo'
DECLARE @referencia varchar(50), @modalidad varchar(50), @tipo_doc int
DECLARE db_cursor CURSOR FOR
select referencia,modalidad,tipo_doc
from LN_score_referencias
where cliente = @cliente and familia = @familia order by modalidad desc
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @referencia, @modalidad, @tipo_doc
WHILE @@FETCH_STATUS = 0
BEGIN
declare @killer int,@killer_descripcion varchar(50)
declare @doc_id int
declare @estado_docs int
declare @cantidad_docs int
declare @campo char(1)
if(@modalidad = 'VERIFICACION')
begin
set @cantidad_docs =
(select count(doc_id)
from ln_docs
inner join LN_score_referencias on LN_score_referencias.cliente = ln_docs.cliente
where contraparte = @contraparte and ln_docs.tipo_doc = @tipo_doc and dependencia = 1 and aplica = 1 ) --and estado_doc = 'V'
set @estado_docs =
(select count(doc_id)
from ln_docs
inner join LN_score_referencias on LN_score_referencias.cliente = ln_docs.cliente
where contraparte = @contraparte and ln_docs.tipo_doc = @tipo_doc and dependencia = 1 and aplica = 1 and estado_doc = 'V')
select @cantidad_docs
if(@cantidad_docs != @estado_docs)
begin
set @killer = 1
set @killer_descripcion = @modalidad
end
-- set @doc_id = (select doc_id from LN_docs where cliente = @cliente and contraparte = @contraparte and tipo_doc = @tipo_doc)
-- select estado_doc from LN_docs where tipo_doc = @tipo_doc and contraparte = @contraparte and cliente = @cliente
end
--select * FROM LN_doc_campos
if(@modalidad = 'BUSCAR_CAMPO')
BEGIN
set @campo = (select tipo_campo from ln_tipo_doc_campos inner join LN_campos on LN_campos.campo = ln_tipo_doc_campos.campo where campo_id = @referencia)
set @doc_id = (select doc_id from LN_docs where cliente = @cliente and contraparte = @contraparte and tipo_doc = (select tipo_doc from LN_tipo_doc_campos where campo_id = @referencia))
select
case
when @campo = 'T' then valor_texto
when @campo = 'N' then valor_numerico
when @campo = 'D' then valor_fecha
when @campo ='B' then valor_numerico
when @campo ='S' then valor_texto
when @campo ='M' then valor_texto
when @campo ='R' then valor_numerico
when @campo ='C' then valor_numerico
when @campo ='F' then valor_texto
when @campo ='L' then valor_texto
when @campo ='G' then valor_texto
end
FROM LN_doc_campos where doc_id = @doc_id
-- select @doc_id
END
if(@killer = 1)
begin
select @killer_descripcion as killer_descripcion
BREAK;
end
-- [LN_obtener_score_personalizado] 5546348,27,352
FETCH NEXT FROM db_cursor INTO @referencia, @modalidad, @tipo_doc
END
CLOSE db_cursor
DEALLOCATE db_cursor
END
/*
select * from padrones where id_padron = 1003936
select * from LN_contrapartes where contraparte = 352
select doc_id from LN_docs where cliente = '5546348' and contraparte = 352 and tipo_doc = 1071
select * from LN_tipos_doc where tipo_doc = 1005
select top 100 * from LN_tipo_doc_campos where tipo_doc = 1071 order by campo_id
select * from LN_tipos_doc where tipo_doc = 1071
select top 100 * from LN_tipo_doc_campos where campo = 165 order by campo_id
select * from ln_doc_campos where campo = 165 and doc_id = 10122
--insert into LN_score_referencias (cliente,familia,referencia,modalidad) values (5546348,27,'AMX_CORRUPCION','BUSCAR_CAMPO')
--insert into LN_score_referencias (cliente,familia,tipo_doc,modalidad) values (5546348,27,1005,'VERIFICACION')
select * from LN_score_referencias where cliente = 5546348*/
GO
Depends On
5Used By
No items found