USE [Database]

--<< 1
SELECT [p].[id], [p].[name], [pt].[id], [pt].[name]
FROM [Tables].[product_types] AS [pt]
LEFT JOIN [Tables].[products] AS [p]
  ON [p].[product_type_id] = [pt].[id]

BEGIN TRY
  EXECUTE [Procedures].[insert_product_type] 23, N'Orbit';
END TRY
BEGIN CATCH
  PRINT N'The error occurred - the right case'
END CATCH

--<< 2
EXECUTE [Procedures].[specify_product_type] 23, N'Orbit';

SELECT [p].[id], [p].[name], [pt].[id], [pt].[name]
FROM [Tables].[product_types] AS [pt]
LEFT JOIN [Tables].[products] AS [p]
  ON [p].[product_type_id] = [pt].[id]

--<< 3
EXECUTE [Procedures].[insert_product_type] 23, N'Mentos';

SELECT [p].[id], [p].[name], [pt].[id], [pt].[name]
FROM [Tables].[product_types] AS [pt]
LEFT JOIN [Tables].[products] AS [p]
  ON [p].[product_type_id] = [pt].[id]

--<< 4
 UPDATE [Tables].[products]
SET [product_type_id] = (
  SELECT [id] 
  FROM [Tables].[product_types] 
  WHERE [name] = N'Mentos'
)
WHERE UPPER([name]) LIKE N'%MENTOS%';

SELECT [p].[id], [p].[name], [pt].[id], [pt].[name]
FROM [Tables].[product_types] AS [pt]
LEFT JOIN [Tables].[products] AS [p]
  ON [p].[product_type_id] = [pt].[id]