Create a procedure that returns the most recent order

Assignment Help PL-SQL Programming
Reference no: EM131506674

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.

Reference no: EM131506674

Questions Cloud

Which of given choices is not a category of check tampering : Which of the following choices is not a category of check tampering? Which of the following computer audit tests can be used to detect forged maker schemes?
Identify which biological concepts are relevant to the topic : Discuss your opinion on how research on this topic should be funded. State whether you think taxpayer monies should support research on this topic.
What percent of her yearly salary must sara put aside : Sanjay has 100 euros to spend before he flies back to the United States. He wishes to purchase jewelry priced at $160 (U.S.) in a duty-free shop at the airport.
Identify significant tax and nontax issues or concerns : Identify significant tax and nontax issues or concerns that may differ across entity types and discuss how they are relevant to choice of entity decision entity
Create a procedure that returns the most recent order : 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.
How is morality different from ethics according to feeney : What does Espinosa mean by children experiencing "double-jeopardy?" How is morality different from ethics, according to Feeney
Will project meet the company economic decision criterion : An automobile manufacturing company in Country X is considering the construction and operation of a large plant on the eastern seaboard of the United States.
Five differences between popular and scholarly sources : Explain at least five differences between popular and scholarly sources used in research for airport security and minimum wage
What are pitfalls in interpreting the internal revenue code : What are pitfalls in interpreting the Internal Revenue Code? Which of the following is characteristic of the IRS audit procedure?

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  Create a procedure named basket

After a shopper completes an order, a procedure is called to update the following columns in the Basket table: orderplaced, subtotal, shipping, tax and total.

  Write a select statement that returns these columns

Write a SELECT statement that returns these columns from the Products table: The date_added column A column that uses the CAST function to return the date_added column with its date only (year, month, and day)

  Create a new access database and set up a table

Create a new Access database and set up a table named Sales Rep. Be sure to create attributes, set a primary key, select data types, and add descriptions as necessary. Use the following information:

  Computer science assistance

Look up the altitude of a Globalstar satellite on the Internet. Use Kepler's formula to check the accuracy of a given period and altitude for a Globalstar satellite. Use the following exponent calculator to estimate the period.

  Write single query that retrieves information for management

If a customer has no rentals, or did not rent any movies multiple times, management does not want to see them in the list. Write a single query that retrieves this information for management.

  Write the sql code to perform the tasks

Write the SQL code to perform the tasks requested in each problem. Screenshots are required for each SQL statement for a grade to be given.

  Use the provided appbdbcreatesql sql script to create the

use the provided appbdbcreate.sql sql script to create the database to be used when working on this assignment.question

  Find the sum of the elements of a

A is an ArrayList of size N. The elements of A are integers, they are in sorted order increasing from the low end of the array, and no two integers are the same. Variable x is an integer. Which of the following operations takes time that is less t..

  Write a perl subroutine for temperature conversion

Write a perl subroutine for temperature conversion named 'convert_temp'. It should be able to handle both Fahrenheit to Celsius conversions as well as Celsius to Fahrenheit conversions.

  An er diagram for the system

An ER diagram for the system. Show all entities, relationships, cardinalities and optionalities. Also, include all intersection entities. You must use the Finkelstein methodology as per the study book and tutorials.

  Create an sql query that uses an uncorrelated subquery

Create an SQL query that USES AN UNCORRELATED SUBQUERY2 AND NO JOINS3 to display the descriptions for products provided by a vendor in area code 615.

  Population of alligators on the kennedy space

In 1970 the population of alligators on the Kennedy Space Center grounds was estimated to be 300. In 1980 the population had grown to an estimated 1500. Using the Malthusian law for population growth, estimate the alligator population on the Kenne..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd