0% found this document useful (0 votes)
18 views3 pages

Assignment3 B

COmp 214 assignment 3

Uploaded by

Pratik Nepal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Assignment3 B

COmp 214 assignment 3

Uploaded by

Pratik Nepal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Advanced Database COMP214

Assignment #3 – Cursors, Procedures & Functions

Due Date: As per dropbox

Purpose: The purpose of this assignment is to help you:


 Become familiar with Cursors, Exceptions, Procedures and Functions

Instructions: Be sure to read the following general instructions carefully:


This assignment should be completed individually by all the students. Submit your
solution through the dropbox. Your submission should include PL/SQL code, the
submission must be named according to the following rule:
studentID(yourlastname)_Assignment#number.txt. e.g.,
300123456(smith)_Assignment#3.txt

Questions [8 marks]

Answer Questions 1-4 related to


Chapter 5 of Oracle 11g: PL/SQL Programming.
Your files must be in sql script format so that they can be run in SQL Developer and have
DBMS_OUTPUT.PUT_LINE for presenting results. Has to have separate testing code for all
programming units.
Submit code in in .txt file
Marks are and will entirely based only on correct result of code submitted having testing part.

1. The home page of the Brewbean's Web site has an option for members to log on with
their IDs and passwords. Develop a procedure named MEMBER_CK_SP that accepts
the ID and password as inputs, checks whether they make up a valid logon, and returns
the member name and cookie value. The name should be returned as a single text string
containing the first and last name.

The head developer wants the number of parameters minimized so that the same

parameter is used to accept the password and return the name value. Also, if the user
doesn't enter a valid username and password, return the value INVALID in a parameter
named p_check. Test the procedure using a valid logon first, with the username rat55
and password kile. Then try it with an invalid logon by changing the username to rat.

Assignment #3 Page 1 of 3
Advanced Database COMP214

2. Create a procedure named DDPAY_SP that identifies whether a donor currently has an
completed pledge with no monthly payments. A donor ID is the input to the procedure.
Using the donor ID, the procedure needs to determine whether the donor has any
currently completed pledges based on the status field and is/was not on a monthly
payment plan. If so, the procedure is to return the Boolean value TRUE. Otherwise, the
value FALSE should be returned. Test the procedure with an anonymous block.

3. Create a procedure named DDCKPAY_SP that confirms whether a monthly pledge


payment is the correct amount. The procedure needs to accept two values as input: a
payment amount and a pledge ID. Based on these inputs, the procedure should confirm
that the payment is the correct monthly increment amount, based on pledge data in the
database. If it isn't, a custom Oracle error using error number 20050 and the message
"Incorrect payment amount - planned payment = ??" should be raised. The ?? should be
replaced by the correct payment amount. The database query in the procedure should be
formulated so that no rows are returned if the pledge isn'ton a monthly payment plan or
the pledge isn't found. If the query returns no rows, the procedure should display the
message "No payment information." Test the procedure with the pledge ID 104 and the
payment amount $25. Then test with the same pledge ID but the payment amount
$20.Finally,test the procedure with a pledge ID for a pledge that doesn't have monthly
payments associated with it.

4. The Reporting and Analysis Department has a database containing tables that hold
summarized data to make report generation simpler and more efficient. They want to
schedule some jobs to run nightly to update summary tables. Create two procedures to
update the following tables(assuming that existing data in the tables is deleted before
these procedures run):

Create the PROD_SALES_SUM_SP procedure to update the BB_PROD_SALES

table, which holds total sales dollars and total sales quantity by product ID, month,

and year. The order date should be used for the month and year information.

Create the SHOP_SALES_SUM_SP procedure to update the BB_SHOP_SALES

Assignment #3 Page 2 of 3
Advanced Database COMP214

table, which holds total dollar sales by shopper ID. The total should include only

product amounts—no shipping or tax amounts.

The BB_SHOP_SALES and BB_PROD_SALES tables have already been created.


Use the

DESCRIBE command to review their table structures. Run pl/sql block to execute
and present results for both procedures.

Assignment #3 Page 3 of 3

You might also like