Create A Host Variable Named Gtax To Hold The Value PDF
Create A Host Variable Named Gtax To Hold The Value PDF
1/3
1. Date cutoff = Any customers who have not shopped on the site since this date should be
included as incentive participants. Use the basket creation date to reflect shopper activity dates.
2. Month = Three-character month (such as APR) that should be added to the promotion table
to indicate which month the free shipping is available.
3. Year = Four-digit year indicating the year the promotion is effective.
4. PROMO_FLAG = 1 (representing free shipping).
The BB_PROMOLIST table also has a USED column, which contains a default value of “N”
and is updated to a “Y” when the shopper uses the promotion. Test the procedure with a cutoff
date of 15-FEB-03. Assign the free shipping for the month of APR and the year 2003.
Question 4. Calculate the Total Shopper Spending
Many of the reports generated from the system calculate the total dollars in purchases for a
shopper. Complete the following steps to create a function named TOT_PURCH_SF that
accepts a shopper id as input and returns the total dollars that the shopper has spent with the
company. Use the function in a SELECT statement that shows the shopper id and total
purchases for every shopper in a database.
1. Develop and run a CREATE FUNCTION statement to create the TOT_PURCH_SF function.
The function code needs a formal parameter for the shopper id and to sum the total column
from the BB_BASKET table.
2. Develop a SELECT statement using the BB_SHOPPER table to produce a list of each
shopper in the database and his or her respective totals.
Question 5. Calculate Days Between Ordering and Shipping
An analyst in the quality assurance office reviews the time lapse between receiving an order
and shipping an order. Any orders that have not been shipped within a day of the order being
placed are investigated. Create a function named ORD_SHIP_SF that calculates the number of
days between the date the basket was created and the shipping date. The function should
return a character string that indicates “OK” if the order was shipped within a day or “CHECK”
if it was not. The IDSTAGE column of the BB_BASKETSTATUS table indicates the item is
shipped with a value of 5 and the DTSTAGE column is the shipping date. The TDORDERED
column of the BB_BASKET table is the order date. Use the function in an anonymous block that
uses a host variable to receive the basket id to check basket 3.
Question 6. Perform Exception Handling with User-Defined Errors
On occasion, some of Brewbean’s customers mistakenly leave an item out of a basket already
checked out, so they create a new basket containing the missing items. However, they request
that the baskets be combined so that they are not charged extra shipping. A screen has been
developed to allow an employee to modify the basket id of items in the BB_BASKETITEM table
to another to another existing basket to combine the baskets. A block has been constructed to
support this screen and can be found at the end of this question. However, an exception needs
to be added to trap the situation in which an invalid basket id is entered for the original basket.
In this case, the UPDATE affects no rows but does not raise an Oracle error. The handler
should display a message stating “invalid original basket id”. Use a host variable named
G_OLD with a value of 30 and a host variable named G_NEW with a value of 4 to provide the
values to the block. First verify that no item rows exist in the BB_BASKETITEM table with a
basket id of 30.
BEGIN
UPDATE bb_basketitem
SET idBasket = :g_new
WHERE idBasket = :g_old;
END;
/
2/3
Create a host variable named gtax to hold the value
3/3
Powered by TCPDF (www.tcpdf.org)