﻿DROP PROCEDURE IF EXISTS uspGetDictionaryItemBaseNyelvByDictionaryItemId
GO

CREATE PROCEDURE uspGetDictionaryItemBaseNyelvByDictionaryItemId
   @pDictionaryItemId int = NULL
  ,@pTanevId int = NULL
  ,@pIntezmenyId int = NULL
AS
BEGIN  
  SET NOCOUNT ON;

DECLARE @sql NVARCHAR(MAX)
SET @sql = ''
SET @sql = 
  'SELECT 
     ID
    ,C_NAME
    ,C_NAME_1
    ,C_NAME_2
    ,C_NAME_3
    ,C_NAME_4
    ,C_NYELVID
    ,C_SHORTNAME
    ,C_DICTIONARYITEMBASEID 
  FROM T_DICTIONARYITEMBASENYELV_OSSZES
    WHERE TOROLT = ''F'' '
    +IIF(@pIntezmenyId IS NOT NULL,'  AND C_INTEZMENYID = @pIntezmenyId ', '')
    +IIF(@pTanevId IS NOT NULL,'  AND C_TANEVID = @pTanevId ', '')
    +IIF(@pDictionaryItemId IS NOT NULL,'  AND C_DICTIONARYITEMBASEID = @pDictionaryItemId ', '') 

  EXEC sp_executesql @sql
      ,N'@pIntezmenyId int
        ,@pTanevId int
        ,@pDictionaryItemId int'
      ,@pIntezmenyId = @pIntezmenyId
      ,@pTanevId = @pTanevId
      ,@pDictionaryItemId = @pDictionaryItemId

END 
GO
