Chapter Eleven – The Web Server Environment
Page 11–41
H. Write a stored procedure that receives values for InvoiceNumber and NewStatus and
that sets the value of Status to NewStatus for the row having the given value of
InvoiceNumber. Generate an error message if no row has the given value of
InvoiceNumber. Using your sample database, demonstrate that your stored procedure
works.
Here is the code for the stored procedure:
CREATE OR ALTER ROCEDURE [dbo].[Update_Status]
@InvoiceNumber Int,
@newStatus Char(12)
IF @rowCount = 0
BEGIN
PRINT ‘======================================================================’
PRINT ”
PRINT ‘ There is no Order with Invoice Number: ‘ + CONVERT(Char(12),@InvoiceNumber)
PRINT ”
PRINT ‘ No Action Taken’
PRINT ”
PRINT ‘======================================================================’
RETURN
END
/* The Order exists, so update status */