Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use AP database and the stored procedure named: spBalanceRange. What causes the ELSE clause to be executed When @VendorVar exactly equals a Vendors full name
Use AP database and the stored procedure named: spBalanceRange.
What causes the ELSE clause to be executed
When @VendorVar exactly equals a Vendors full name | ||
When the @BalanceMax is > 0 | ||
When the @BalanceMin is < 0 | ||
Nothing, it will never be executed because the code is written incorrectly |
The code for the SpBalance range is
CREATE PROC spBalanceRange @VendorVar varchar(50) = '%', @BalanceMin money = 0, @BalanceMax money = 0 AS IF @BalanceMax = 0 BEGIN SELECT VendorName, InvoiceNumber, InvoiceTotal - CreditTotal - PaymentTotal AS Balance FROM Vendors JOIN Invoices ON Vendors.VendorID = Invoices.VendorID WHERE VendorName LIKE @VendorVar AND (InvoiceTotal - CreditTotal - PaymentTotal) > 0 AND (InvoiceTotal - CreditTotal - PaymentTotal) >= @BalanceMin ORDER BY Balance DESC; END; ELSE BEGIN SELECT VendorName, InvoiceNumber, InvoiceTotal - CreditTotal - PaymentTotal AS Balance FROM Vendors JOIN Invoices ON Vendors.VendorID = Invoices.VendorID WHERE VendorName LIKE @VendorVar AND (InvoiceTotal - CreditTotal - PaymentTotal) > 0 AND (InvoiceTotal - CreditTotal - PaymentTotal) BETWEEN @BalanceMin AND @BalanceMax ORDER BY Balance DESC; END; --15-02a, 2b, 2c -- test code EXEC spBalanceRange 'M%'; EXEC spBalanceRange @BalanceMin = 200, @BalanceMax = 1000; EXEC spBalanceRange '[C,F]%', 0, 200;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started