﻿DECLARE intezmenytanevekCursor CURSOR LOCAL FOR 
	SELECT C_INTEZMENYID, C_TANEVID
		FROM T_INTEZMENYADATOK

DECLARE @intezmenyId int, @tanevId int

OPEN intezmenytanevekCursor  
FETCH NEXT FROM intezmenytanevekCursor INTO @intezmenyId, @tanevId

WHILE @@FETCH_STATUS = 0 
BEGIN  
	PRINT N'INTÉZMÉNY ID: ' + CAST(@intezmenyId AS NVARCHAR(10)) + N', TANÉV ID: ' + CAST(@tanevId AS NVARCHAR(10))

	SET IDENTITY_INSERT [dbo].[T_DICTIONARYITEMBASE] ON

		INSERT INTO dbo.T_DICTIONARYITEMBASE (ID, C_NAME, C_NAME_1, C_NAME_2, C_NAME_3, C_NAME_4, C_TYPE, C_PROTECTED, C_VISIBLE, C_ORDER, C_CODE, C_VALUE, C_COLOR, C_INTEZMENYID, C_TANEVID, TOROLT, SERIAL, LASTCHANGED, CREATED, MODIFIER, CREATOR)
		VALUES
			(6853, N'Táppénz', N'Táppénz', NULL, NULL, NULL, N'IgazolasTipus', N'F', N'T', 8, NULL, 8, NULL, @IntezmenyId, @TanevId, 'F', 0, GETDATE(), GETDATE(), NULL, NULL)

    SET IDENTITY_INSERT [dbo].[T_DICTIONARYITEMBASE] OFF

		INSERT INTO [dbo].[T_IGAZOLASTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]) VALUES
			(6853, @IntezmenyId, @TanevId)

	FETCH NEXT FROM intezmenytanevekCursor INTO @intezmenyId, @tanevId
END  

CLOSE intezmenytanevekCursor  
DEALLOCATE intezmenytanevekCursor

GO

UPDATE T_DICTIONARYITEMBASE SET
  C_ORDER = 9,
  C_VALUE = 9
WHERE ID = 1529
  AND TOROLT = N'F'

GO

