USE [Database]

DECLARE
 @article_number_attribute_id AS INT,
 @barcode_attribute_id AS INT,
 @date_of_manufacture_attribute_id AS INT,
 @expiration_date_attribute_id AS INT;

SET @article_number_attribute_id =
 (SELECT [id]
  FROM [Tables].[attributes] 
  WHERE [name] = N'Article number');
SET @barcode_attribute_id =
 (SELECT [id]
  FROM [Tables].[attributes] 
  WHERE [name] = N'Barcode');
SET @date_of_manufacture_attribute_id =
 (SELECT [id]
  FROM [Tables].[attributes] 
  WHERE [name] = N'Date of manufacture');
SET @expiration_date_attribute_id =
 (SELECT [id]
  FROM [Tables].[attributes] 
  WHERE [name] = N'Expiration date');

DECLARE
  @product_id_1 AS INT,
  @product_id_2 AS INT,
  @product_id_3 AS INT,
  @product_id_4 AS INT;

EXECUTE [Procedures].[insert_product] 
  @name = N'Hobby World Карточная игра Ужас Аркхэма',
  @product_type_id = 9, -- Настольные игры
  @barcode_attribute_id = @barcode_attribute_id,
  @inserted_product_id = @product_id_1 OUTPUT;
EXECUTE [Procedures].[insert_product]
  @name = N'Жевательная резинка Orbit Mega Клубника, без сахара, 16,4 г',
  @product_type_id = 23, -- Жевательная резинка
  @barcode_attribute_id = @barcode_attribute_id,
  @inserted_product_id = @product_id_2 OUTPUT;
EXECUTE [Procedures].[insert_product]
  @name = N'Жевательная резинка Mentos Pure White вкус Клубника, 15,5 г',
  @product_type_id = 23, -- Жевательная резинка
  @barcode_attribute_id = @barcode_attribute_id,
  @inserted_product_id = @product_id_3 OUTPUT;
EXECUTE [Procedures].[insert_product]
  @name = N'Печенье Oreo, с какао и начинкой со вкусом клубники, 228 г',
  @product_type_id = 22, -- Печенье
  @barcode_attribute_id = @barcode_attribute_id,
  @inserted_product_id = @product_id_4 OUTPUT;

INSERT INTO [Tables].[product_attributes]([product_id], [attribute_id])
VALUES
  (@product_id_2, 3),
  (@product_id_2, 4),
  (@product_id_3, 3),
  (@product_id_3, 4);

INSERT INTO [Tables].[product_values]([product_id], [attribute_id], [value])
VALUES
  (2, 3, N'1900-01-01'), -- Дата изготовления
  (2, 4, N'3650'),       -- Срок годности
  (3, 3, N'1900-01-01'),
  (3, 4, N'30');