﻿
DROP TABLE IF EXISTS tmpForSwitchDictionaryItemBase 
CREATE TABLE tmpForSwitchDictionaryItemBase(RegiID int, UjID int, TanevID int, C_NAME nvarchar(500), C_TYPE nvarchar(64))
DECLARE @TEMP_EnvironmentName nvarchar(1000) 
SET @TEMP_EnvironmentName = (SELECT TOP 1 [Value] 
FROM dev.EnvironmentInfo WHERE [Key] = 'Kornyezet')
 IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 8394, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021'
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' 
    ,DIB.C_NAME_1 = N'Ksz/13' 
    ,DIB.C_TYPE = N'EvfolyamTipus' 
    ,DIB.C_CODE = N'004' 
    ,DIB.C_PROTECTED = N'T' 
    ,DIB.C_VISIBLE = N'F' 
    ,DIB.C_ORDER = 4560 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.ID = 8394;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 8394, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021'
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' 
    ,DIB.C_NAME_1 = N'Ksz/13' 
    ,DIB.C_TYPE = N'EvfolyamTipus' 
    ,DIB.C_CODE = N'004' 
    ,DIB.C_PROTECTED = N'T' 
    ,DIB.C_VISIBLE = N'T' 
    ,DIB.C_ORDER = 4560 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.ID = 8394;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 8394, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021'
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' 
    ,DIB.C_NAME_1 = N'Ksz/13' 
    ,DIB.C_TYPE = N'EvfolyamTipus' 
    ,DIB.C_CODE = N'004' 
    ,DIB.C_PROTECTED = N'T' 
    ,DIB.C_VISIBLE = N'T' 
    ,DIB.C_ORDER = 4560 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.ID = 8394;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 8394, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021'
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'Ksz/13 4-es szintű szakképző iskola közismeret nélküli' 
    ,DIB.C_NAME_1 = N'Ksz/13' 
    ,DIB.C_TYPE = N'EvfolyamTipus' 
    ,DIB.C_CODE = N'004' 
    ,DIB.C_PROTECTED = N'T' 
    ,DIB.C_VISIBLE = N'T' 
    ,DIB.C_ORDER = 4560 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.ID = 8394;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 8395, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021'
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'3/15 5-ös szintű technikum' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'3/15 5-ös szintű technikum' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'3/15 5-ös szintű technikum' 
    ,DIB.C_NAME_1 = N'3/15' 
    ,DIB.C_TYPE = N'EvfolyamTipus' 
    ,DIB.C_CODE = N'004' 
    ,DIB.C_PROTECTED = N'T' 
    ,DIB.C_VISIBLE = N'F' 
    ,DIB.C_ORDER = 4345 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.ID = 8395;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 8395, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021'
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'3/15 5-ös szintű technikum' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'3/15 5-ös szintű technikum' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'3/15 5-ös szintű technikum' 
    ,DIB.C_NAME_1 = N'3/15' 
    ,DIB.C_TYPE = N'EvfolyamTipus' 
    ,DIB.C_CODE = N'004' 
    ,DIB.C_PROTECTED = N'T' 
    ,DIB.C_VISIBLE = N'T' 
    ,DIB.C_ORDER = 4345 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.ID = 8395;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 8395, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021'
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'3/15 5-ös szintű technikum' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'3/15 5-ös szintű technikum' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'3/15 5-ös szintű technikum' 
    ,DIB.C_NAME_1 = N'3/15' 
    ,DIB.C_TYPE = N'EvfolyamTipus' 
    ,DIB.C_CODE = N'004' 
    ,DIB.C_PROTECTED = N'T' 
    ,DIB.C_VISIBLE = N'T' 
    ,DIB.C_ORDER = 4345 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.ID = 8395;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 8395, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021'
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'3/15 5-ös szintű technikum' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.C_TYPE = N'EvfolyamTipus' AND DIB.C_NAME = N'3/15 5-ös szintű technikum' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'3/15 5-ös szintű technikum' 
    ,DIB.C_NAME_1 = N'3/15' 
    ,DIB.C_TYPE = N'EvfolyamTipus' 
    ,DIB.C_CODE = N'004' 
    ,DIB.C_PROTECTED = N'T' 
    ,DIB.C_VISIBLE = N'T' 
    ,DIB.C_ORDER = 4345 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_NEV = '2020/2021' 
    WHERE DIB.ID = 8395;
  END
 EXEC [dev].uspSwitchDictionaryItemBaseFromTmp 
 EXEC[dev].[uspCreateDictionaryItems] NULL, NULL 