Question: 1) Functions: a. Create a function that has the Customer_id as input and returns a number that represents the total cost of orders for this

1) Functions: a. Create a function that has the Customer_id as input and returns a number that represents the total cost of orders for this customer. Notice that you will need to multiply the Order_Qty from table order_details and the Unit_Price from table items to get the total cost of each order. b. Now use the function: Write a select statement that selects all the customers and the total cost of the orders they have ever made. 2) Procedure: a. Write a procedure that has as input the customer_id. Then the procedure should delete the corresponding customer from table customers. b. Notice that customer_id is a foreign key on table orders. Therefore, the customer cannot be deleted if he has placed orders. To delete a record from customers you should first delete the corresponding orders and to do that you need to first delete the corresponding order_details. c. Now execute the procedure to delete customer with id 1. d. ROLLBACK; and all these changes will be undone!
...... CUSTOMERS - CUSTOMER_ID - CUSTOMER_FIRST_NAME - CUSTOMER_LAST_NAME 1 CUSTOMER_ADDRESS CUSTOMER_CITY - CUSTOMER_STATE - CUSTOMER_ZIP CUSTOMER_PHONE 0 CUSTOMER_FAX CUSTOMERSHIPADDRESS_T DOESBUSINESSIN_T DRIVER_INFO EMPLOYEE_T EMPLOYEESKILLS_T GENERAL_LEDGER_ACCOUNTS INVOICE_LINE_ITEMS INVOICES ITEMS ITEM_ID TITLE - 1 ARTIST 1 UNIT_PRICE ORDER_DETAILS I ORDER_ID ITEM_ID I ORDER_QTY ORDER_T ORDERLINE_T ORDERS I ORDER_ID - CUSTOMER_ID - ORDER_DATE - SHIPPED_DATE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
