dbo.backend_obtener_identificadores_pais

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

2
Name Data Type Length Description
@country_code varchar 2
@tipoIdent varchar 1

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO

--EXEC backend_obtener_identificadores_pais 'PY', 'F'
/*EXEC backend_obtener_identificadores_pais 'AR', 'F'*/

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE  dbo.backend_obtener_identificadores_pais
 -- Add the parameters for the stored procedure here
 @country_code      varchar(2),
    @tipoIdent                          VARCHAR(1)= 'T'
 
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 (@country_code = 'AR' and @tipoIdent ='T')
        begin 
            SELECT identificadores.identificador, identificadores.abreviatura, identificadores.nombre_identificador,
            identificadores.country_code, country.country_code from identificadores inner join country on
            identificadores.country_code = country.country_code
            where country.country_code = @country_code
            and identificadores.identificador IN ('CUIT', 'CUIL', 'CDI')
            order by isnull(identificadores.orden,9999), identificadores.abreviatura
        end
 
  if (@country_code = 'AR' and @tipoIdent !='T')
            begin        
     SELECT identificadores.identificador, identificadores.abreviatura, identificadores.nombre_identificador,
    identificadores.country_code, country.country_code from identificadores inner join country on
    identificadores.country_code = country.country_code
    where country.country_code = @country_code and identificadores.tipo_ident = @tipoIdent
    and identificadores.identificador IN ('DNI','ARPASS')
    order by isnull(identificadores.orden,9999), identificadores.abreviatura
   end

  if (@country_code != 'AR' and @tipoIdent ='T')
            begin        
     SELECT identificadores.identificador, identificadores.abreviatura, identificadores.nombre_identificador,
    identificadores.country_code, country.country_code from identificadores inner join country on
    identificadores.country_code = country.country_code
    where country.country_code = @country_code 
    /*and identificadores.tipo_ident = @tipoIdent*/
    order by isnull(identificadores.orden,9999), identificadores.abreviatura
   end
  if (@country_code != 'AR' and @tipoIdent in ('F','M'))
            begin        
     SELECT identificadores.identificador, identificadores.abreviatura, identificadores.nombre_identificador,
    identificadores.country_code, country.country_code from identificadores inner join country on
    identificadores.country_code = country.country_code
    where country.country_code = @country_code 
    and identificadores.tipo_ident = @tipoIdent
     order by isnull(identificadores.orden,9999), identificadores.abreviatura
   end


/*
    if (@tipoIdent !='T')
            begin        
                SELECT identificadores.identificador, identificadores.abreviatura, identificadores.nombre_identificador,
                identificadores.country_code, country.country_code from identificadores inner join country on
                identificadores.country_code = country.country_code
                where country.country_code = @country_code and identificadores.tipo_ident = @tipoIdent
                order by identificadores.abreviatura
            end
        ELSE
            begin
                SELECT identificadores.identificador, identificadores.abreviatura, identificadores.nombre_identificador,
                identificadores.country_code, country.country_code from identificadores inner join country on
                identificadores.country_code = country.country_code
                where country.country_code = @country_code
                order by identificadores.abreviatura
            end
*/

END

GO

Used By

No items found