which capture, among others, the items that are ordered by customers. Explain what the following code is and explain how it works by writing comments against each line of the code:

Assume the following tables:
Order(orderNo, statusCode, customerNo,…)
Item(itemNo, orderNo, price, amount,…)


FUNCTION total_sales (customerNo_in IN orders.customerNo%TYPE,
statusCode_in IN order.statusCode%TYPE:=NULL)
RETURN NUMBER
IS
statusCode_int order.statusCode%TYPE:= UPPER(statusCode_in);
CURSOR salesCur (statusCode_in IN statusCode%TYPE) IS
SELECT SUM (price*amount)
FROM item
WHERE EXISTS (select ‘x’ FROM Order
WHERE order.orderNo = item.orderNo AND customerNo = customerNo_in
AND statusCode = statusCode_in);

returnValue NUMBER;
BEGIN
OPEN salesCur (statusCode_int);
FETCH salesCur INTO returnValue;
IF salesCur%notfound
THEN
CLOSE salesCur;
RETURN NULL;
ELSE
CLOSE salesCur;
RETURN returnValue;
END IF;
END total_sales;

The student should be able to explain the main points of the function: the structure, the meaning and type of the parameters, the cursor, variables, the embedded SQL statement and the main executable body.

Computer Science & Information Technology

You might also like to view...

What practice addresses the ability to make authorized changes and detect unauthorized changes and activities using process like application behavior monitoring and diagnostics?

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

The item marked 5 in the accompanying figure is the icon for the ____ panel.

a. Paths b. Adjustments c. Character d. Paragraph

Computer Science & Information Technology

How do you create new objects in Java?

a. How do you create a World object? b. How do you create a Turtle object?

Computer Science & Information Technology

Line comments start with ____.

A. a forward slash and an asterisk B. two forward slashes C. a forward slash and two asterisks D. a percent sign

Computer Science & Information Technology