Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions