dbo.LN_clientes_tipo_doc

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

2
Name Data Type Length Description
@p_country_code varchar 20
@p_cliente 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_clientes_tipo_doc 
 -- Add the parameters for the stored procedure here
 @p_country_code       varchar(20) = null,
 @p_cliente        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

 if (@p_cliente is null AND @p_country_code is null)

  select tipo_doc, nombre_tipo_doc
  from LN_tipos_doc
  order by nombre_tipo_doc

 else
  
  if (@p_cliente is not null AND @p_country_code is null)
 
   select LN_tipos_doc.tipo_doc, LN_tipos_doc.nombre_tipo_doc
   from LN_tipos_doc 
   inner join LN_producto_tipo_doc ON LN_tipos_doc.tipo_doc = LN_producto_tipo_doc.tipo_doc
   inner join LN_cliente_productos ON LN_producto_tipo_doc.producto = LN_cliente_productos.producto
   where LN_cliente_productos.cliente = @p_cliente
   group by LN_tipos_doc.tipo_doc, LN_tipos_doc.nombre_tipo_doc
   order by LN_tipos_doc.nombre_tipo_doc

  else

   if (@p_cliente is null AND @p_country_code is not null)
   
    select tipo_doc, nombre_tipo_doc
    from LN_tipos_doc
    where country_code = @p_country_code
    order by nombre_tipo_doc

   else

    select LN_tipos_doc.tipo_doc, LN_tipos_doc.nombre_tipo_doc
    from LN_tipos_doc 
    inner join LN_producto_tipo_doc ON LN_tipos_doc.tipo_doc = LN_producto_tipo_doc.tipo_doc
    inner join LN_cliente_productos ON LN_producto_tipo_doc.producto = LN_cliente_productos.producto
    where LN_cliente_productos.cliente = @p_cliente
    and LN_tipos_doc.country_code = @p_country_code
    group by LN_tipos_doc.tipo_doc, LN_tipos_doc.nombre_tipo_doc
    order by LN_tipos_doc.nombre_tipo_doc



END
GO

Used By

No items found