Cis 3010
Cis 3010
Please submit the CODE and OUTPUT for all programming questions. You will submit this assignment
electronically in the ASSESSMENT area of the Study Desk.
For this assignment we will use the Brewers database that comes with the textbook. The script to create the
databases is included as a file in the assignment 1 section of the Moodle course web site. You will need to run
the scripts to create the needed database tables. If you are using you own Oracle insulation the script should
work as normal.
Please Read Carefully.
There are 4 question valued a total of 100 marks. You need to provide a well-structured and commented
solution to the problems. With your code solution you also need to provide a screen shot of the solution output
on your screen. You can use the screen capture features of the OS you are using. For Windows you can use the
print current window capture key stroke Alt-Shift-Print Screen. Depending on your keyboard you may have
to use the function key as well. For Apple Mac use Command (?)-Shift-4 and select screen to capture.
The structures and information about the tables is located in Appendix A (page 423) of the Casteel textbook.
The structure of the tables used in this assignment questions is reproduced below.
BB_SHOPER
BB_BASKET
Write an anonymous block that places a substitution variable (&) into a local variable of type character. You
should check the value entered in the local variable and output different messages depending on the value
provided.
If value is A, output: Please proceed to Level 1
If value is B or C, output: Please proceed to Level 2
If value is D, output: Please proceed to Level 3
In all other entries, output: Invalid Entry
We need a block to categorise the customers according to their total purchases using the BB_BASKET table.
For each customer we determine if they are a of HIGH, MEDIUM or LOW category depending on their
total purchases. Using a host variable to store the customer number the code needs to use an implicit cursor to
sum up the total amount of purchases for that customer. Use another implicit cursor to count the number of
purchases for that customer. Using a conditional block write the code to categorise the customer according to
total phrases. For a HIGH category the purchase is more than $150. For MEDIUM category total purchase
is more than $100. Anything less than $100 is categorised as LOW.
The block should display the following example output after execution
Shopper ID 22 is rated as HIGH with total spend of $XXX.XX and YY number of orders.
Question 3 (30 marks)
Write a PL/SQL that displays the largest total order amount, the highest number of quantity ordered and the
average amount spent on orders in BB_BASKET. Your program must use only explicit cursor/s with basic
looping and must NOT use any aggregate functions such as SUM, MAX, MIN, COUNT and AVG.
(Average is total amount divided by the number of customers)
The output should be formatted as follow.
The highest total order is $xxx.xx
The largest number of items on an order is customer yy.
The average amount for all customers is $xxx.xx
(Hint:BB_BASKET table has the field QUATITY and TOTAL which contain the information you need)
MARKING CRITERIA