2025-06-10 18:37:11 +02:00
|
|
|
-- Create Dictionary
|
2025-04-29 16:46:03 +02:00
|
|
|
DECLARE @JustForDebug TINYINT = 0;
|
|
|
|
|
|
|
|
|
|
-- SETUP VARIABLES
|
|
|
|
|
DECLARE @Number INT = (SELECT COUNT(id) + 1 FROM [diunabi-morska].[dbo].[Layers]);
|
|
|
|
|
DECLARE @Name NVARCHAR(50) = CONCAT(
|
2025-07-04 13:15:47 +02:00
|
|
|
'L', @Number, '-D-D6-SELL-CODES'
|
2025-04-29 16:46:03 +02:00
|
|
|
);
|
|
|
|
|
DECLARE @LayerId UNIQUEIDENTIFIER = NEWID();
|
|
|
|
|
|
2025-06-10 18:37:11 +02:00
|
|
|
SELECT @Name AS Name;
|
2025-04-29 16:46:03 +02:00
|
|
|
|
|
|
|
|
IF @JustForDebug = 1
|
|
|
|
|
BEGIN
|
|
|
|
|
SELECT 'Just for debug' AS Logger;
|
|
|
|
|
RETURN;
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
|
|
INSERT INTO [diunabi-morska].[dbo].[Layers]
|
|
|
|
|
([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type])
|
|
|
|
|
VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 3);
|
|
|
|
|
|
|
|
|
|
DECLARE @Array TABLE (
|
|
|
|
|
Code NVARCHAR(50),
|
|
|
|
|
Desc1 NVARCHAR(50)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
INSERT INTO @Array (Code, Desc1)
|
|
|
|
|
VALUES
|
2025-07-04 13:15:47 +02:00
|
|
|
('1002', '1102'),
|
|
|
|
|
('1003','1202'),
|
|
|
|
|
('1008','1302'),
|
|
|
|
|
('1009','1302'),
|
|
|
|
|
('9085','1203'),
|
|
|
|
|
('1010','1304'),
|
|
|
|
|
('9086','1005'),
|
|
|
|
|
('1021','1206'),
|
|
|
|
|
('9089','1207'),
|
|
|
|
|
('9091','1208')
|
2025-04-29 16:46:03 +02:00
|
|
|
|
|
|
|
|
-- Loop through the array and insert into the target table
|
|
|
|
|
DECLARE @Code NVARCHAR(50);
|
|
|
|
|
DECLARE @Desc1 NVARCHAR(50);
|
|
|
|
|
|
|
|
|
|
DECLARE CursorArray CURSOR FOR
|
|
|
|
|
SELECT Code, Desc1 FROM @Array;
|
|
|
|
|
|
|
|
|
|
OPEN CursorArray;
|
|
|
|
|
|
|
|
|
|
FETCH NEXT FROM CursorArray INTO @Code, @Desc1;
|
|
|
|
|
|
|
|
|
|
WHILE @@FETCH_STATUS = 0
|
|
|
|
|
BEGIN
|
|
|
|
|
INSERT INTO [diunabi-morska].[dbo].[Records]
|
|
|
|
|
([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId])
|
|
|
|
|
VALUES (NEWID(), @Code, @Desc1, GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, @LayerId);
|
|
|
|
|
|
|
|
|
|
FETCH NEXT FROM CursorArray INTO @Code, @Desc1;
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
|
|
CLOSE CursorArray;
|
|
|
|
|
DEALLOCATE CursorArray;
|