Ask PL-SQL Expert

Question 1. Create a procedure named STATUS_SHIP_SP that allows an employee in the Brewbeans' Shipping Department to update an order status to add shipping information. The BB_BASKETSTATUS table lists events for each order so that a shopper can see the status, date, and comments as each stage of the order process is finished. The IDSTAGE column of the BB_BASKETSTATUS table identifies each stage; the value 3 in this column indicates that an order has been shipped.

The procedure should allow adding a row with an IDSTAGE of 3, date shipped, tracking number and shipper. The BB_STATUS_SEQ sequence is used to provide a value for the primary key column. Test the procedure with the following information:
o Basket # = 3
o Date shipped = 20-FEB-12
o Shipper = UPS
o Tracking # = ZW2384YXK4957
create or replace PROCEDURE STATUS_SHIP_SP
(p_id IN OUT BB_BASKETSTATUS.IDSTATUS%TYPE)
IS
BEGIN
p_id := BB_STATUS_SEQ.NEXTVAL;
INSERT INTO BB_BASKETSTATUS (IDSTATUS, IDBASKET, IDSTAGE, DTSTAGE, NOTES, SHIPPER, SHIPPINGNUM)
VALUES (p_id, '3', '3', '20-FEB-12', NULL, 'UPS', 'ZW2384YXK4957');
COMMIT;
END;

377_table.jpg

585_table1.jpg

Question 2. Create a procedure that returns the most recent order status information for a specified basket. This procedure should determine the most recent ordering-stage entry in the BB_BASKETSTATUS table and return the data. Use an IF OR CASE clause to return a stage description instead of an IDSTAGE number, which means little to shoppers. The IDSTAGE column of the BB_BASKETSTATUS table identifies each stage as follows:
o 1-Submitted and received
o 2-Confirmed, processed, sent to shipping
o 3-Shipped
o 4-Cancelled
o 5-Back-ordered
The procedure should accept a basket ID number and return the most recent status description and date the status was recorded. If no status is available for the specified basket ID, return a message stating that no status is available. Name the procedure STATUS_SP. Test the procedure twice with the basket ID 4 and then 6.
CREATE OR REPLACE PROCEDURE STATUS_SP
(
P_RECENT_ORDER IN NUMBER,
p_stat_desc OUT LONG,
p_date OUT DATE
) AS
BEGIN
SELECT BB_BASKETSTATUS.IDBASKET,
BB_BASKETSTATUS.IDSTAGE,
BB_BASKETSTATUS.DTSTAGE

FROM BB_BASKETSTATUS
WHERE BB_BASKETSTATUS.IDBASKET = &P_RECENT_ORDER AND
BB_BASKETSTATUS.DTSTAGE = (SELECT MAX(DISTINCT BB_BASKETSTATUS.DTSTAGE)
FROM BB_BASKETSTATUS
WHERE BB_BASKETSTATUS.IDBASKET = P_RECENT_ORDER);

BEGIN
p_date := BB_BASKETSTATUS.DTSTATUS;
CASE
WHEN BB_BASKETSTATUS.IDSTAGE = 1 THEN p_stat_desc := 'Submitted and recieved';
WHEN BB_BASKETSTATUS.IDSTAGE = 2 THEN p_stat_desc := 'Confirmed, processed, and shipping';
WHEN BB_BASKETSTATUS.IDSTAGE = 3 THEN p_stat_desc := 'Shipped';
WHEN BB_BASKETSTATUS.IDSTAGE = 4 THEN p_stat_desc := 'Cancelled';
WHEN BB_BASKETSTATUS.IDSTAGE = 5 THEN p_stat_desc := 'Back-ordered';
END CASE;
DBMS_OUTPUT.PUT_LINE('Your most recent is: ' || p_stat_desc
|| ' , updated on:' || p_date);
COMMIT;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No status is available');
END STATUS_SP;

Question 3. As a shopper selects products on the Brewbeans' site, a procedure is needed to add a newly selected item to the current shopper's basket. Create a procedure named BASKET_ADD_SP that accepts a product ID, basket ID, price, quantity, size code option (1 or 2), and form code option (3 or 4) and uses this information to add a new item to the BB_BASKETITEM table. The table's PRIMARY KEY column is generated by BB_IDBASKETITEM_SEQ. Run the procedure with the following values:
o Basket ID-14
o Product ID-8az
o Price-10.80
o Quantity-1
o Size code-2
o Form code-4

Question 4. The home page of the Brewbeans' 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. In addition, if the user does not 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.

PL-SQL, Programming

  • Category:- PL-SQL
  • Reference No.:- M92315403
  • Price:- $120

Guranteed 48 Hours Delivery, In Price:- $120

Have any Question?


Related Questions in PL-SQL

Complete the following tasksin microsoft access create the

Complete the following tasks: In Microsoft Access, create the database and tables that you identified in W3 Assignment 2. In Microsoft Word, write the SQL statements to create the database and tables. Write SQL statement ...

Purpose of the assessment with ulo mapping the purpose of

Purpose of the assessment (with ULO Mapping) The purpose of this assignment is to develop skills in managing data in databases and to gain understanding of data model development and implementation using a commercially a ...

Continuing the project you have worked on in weeks 1-4 in

Continuing the project you have worked on in Weeks 1-4, in this final week, complete the following tasks: Refine your database and SQL statements by incorporating your instructor's feedback. Verify that the database comp ...

For this assignment you will be provided a database backup

For this assignment, you will be provided a database backup for a database called FinanceDB. You will have to restore this backup to your own version of SQL Server. All of the questions in this assignment relate to the F ...

Assignment - queries functions and triggersaimthe aims of

Assignment - Queries, Functions and Triggers Aim The aims of this assignment are to: formulate SQL queries; populate an RDBMS with a real dataset, and analyse the data; design test data for testing SQL queries; create SQ ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As