March 2018
Intermediate to advanced
816 pages
19h 35m
English
You can see there is a need for error handling by producing an error. The following code tries to insert an order and a detail row for this order:
EXEC dbo.InsertSimpleOrder @OrderId = 6, @OrderDate = '20160706', @Customer = N'CustE'; EXEC dbo.InsertSimpleOrderDetail @OrderId = 6, @ProductId = 2, @Quantity = 0;
In SQL Server Management Studio, you can see that an error has happened. You should get a message that error 547 has occurred, that the INSERT statement conflicted with the CHECK constraint. If you remember, in order details, only rows where the value for the quantity is not equal to zero are allowed. The error occurred in the second statement, in the call of the procedure that inserts an order detail. The procedure ...