Exercise

FORMATMESSAGE with message string

Every time you sell a bike in your store, you need to check if there is enough stock. You prepare a script to check it and throw an error if there is not enough stock.

Instructions

100 XP
  • Set @sold_bikes to a value greater than @current_stock (e.g. 100).
  • Customize the error using FORMATMESSAGE with the text 'There are not enough %s bikes. You have %d in stock.' as the first parameter, @product_name as the second parameter, and @current_stock as the third parameter.
  • Pass to the THROW statement the @my_message variable and click Run Code (not Run Solution). You will see the error.
  • Set @sold_bikes in DECLARE statement back to 10. Run the code without errors.