Question

An online company sells hundreds of office supply products on its e-Commerce store. It has asked you to design and implement a sales order processing system which will be used by users in our Operations department to process sales orders. Here is an overview of the sales order process. Customers make purchases by placing orders. Each customer has a customer number and profile (such as name, shipping address). To simplify the matter, each time an order is placed, only one item is ordered. The company maintains hundreds of products at various warehouses throughout the United States. Each warehouse has a warehouse code, address and phone number. The company keeps track of products carried in various warehouses and their current inventory level.

create table Customer
(CustomerNumber number(10,0), LastName varchar2(15), FirstName varchar2(15), Address varchar2(50), City varchar2(30), State char(2), ZipCode char(5), PhoneNumber varchar2(12),
constraint customer_pk primary key(CustomerNumber));

create table Warehouse
(WarehouseID varchar2(15), Address varchar2(30), City varchar2(50), State char(2), ZipCode char(5), PhoneNumber varchar2(12),
constraint Warehouse_pk primary key(WarehouseID));

create table Product
(ProductID varchar2(5), Description varchar2(30), Price decimal(4,2),
constraint Product_pk primary key(ProductID));

create table Orders
(OrderID int GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1), CustomerNumber number(10,0), ProductID varchar2(5), Quantity int, OrderDate date default sysdate, OrderStatus varchar2(10), ShippingDate date,
constraint Orders_pk primary key(OrderNum),
constraint Orders_fk1 foreign key(CustomerNumber) references Customer(CustomerNumber)
constraint Orders_fk2 foreign key(ProductID) references Product(ProductID));

create table Inventory(ProductID varchar2(5), WarehouseID varchar2(5), Inventory int,
constraint Inventory_pk primary key(WarehouseID, ProductID),
constraint Inventory_fk1 foreign key(ProductID) references Product(ProductID),
constraint Inventory_fk2 foreign key(WarehouseID) references Warehouse(WarehouseID));

Program 1. open.sql To place an order, the user runs the open.sql program. • The system first prompts the greeting message an

0 0
Add a comment Improve this question Transcribed image text
Answer #1

DECLARE

cust_no number

data Customer%rowtype

item_no number

Item Products%rowtype

quantity number

rc sys_refcursor;

Warehoulse_code varchar2

OrdID number Orders.OrderID%type

BEGIN

cust_no:=&cust_no;

select * into data from Customer WHERE CustomerNumber = cust_no;

dbms_output.put_line('Customer Name: '||data.CustomerNumber );

dbms_output.put_line('Shipping Address: '||data.Address );

dbms_output.put_line('City, State Zip: '||data.City||', '||data.State||' '||data.ZipCode );

dbms_output.put_line('Phone:'||data.PhoneNumber);

item_no:=&item_no

select * into Item from Products where Products.ProductID = item_no

dbms_output.put_line(Item Number: '||item.ProductID);

dbms_output.put_line(Item Description: '||item.Description);

dbms_output.put_line(Unit Price: '||item.Price);

quantity:=&quantity

dbms_output.put_line('Amount Ordered: '||(item.Price)*(item.quantity))

dbms_output.put_line('Please choose from the following Wareshouses:')

open rc for select W.WarehouseID,concat(W.City,",",W.State) as "City,State", Zip as ZipCode, I.Inventory from Warehouse W join Inventory I on (I.wid = W.WarehoulseID);

dbms_sql.return_result(rc);

Warehoulse_code:= &Warehoulse_code ;

insert into Orders (CustomerNumber, ProductID, Quantity, OrderStatus) values(cust_no,item_no,quantity,'Open');

select OrderID into OrdID from Orders where CustomerID = cust_no

dbms_output.put_line('******** Order Status: '||'Open')

dbms_output.put_line('******** Order number is: '||OrdID)

END

Add a comment
Know the answer?
Add Answer to:
An online company sells hundreds of office supply products on its e-Commerce store. It has asked...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For each city, list number of customers from the city, who have placed order(s). Cities are...

    For each city, list number of customers from the city, who have placed order(s). Cities are listed in ascending alphabetical order. Use equal join for this query. CREATE TABLE customer ( cust_id number(11,0) not null, cust_name varchar2(25) not null, street varchar2(30), city varchar2(20), state varchar2(2), zipcode varchar2(5), CONSTRAINT customer_pk PRIMARY KEY (cust_id) ); CREATE TABLE ordertable ( order_id number(11,0) not null, order_date date, cust_id number(11,0), CONSTRAINT order_pk PRIMARY KEY (order_id), CONSTRAINT order_fk FOREIGN KEY (cust_id) REFERENCES customer (cust_id)); CREATE TABLE...

  • Display all customers. If a customer has placed any orders, also display the highest..... Tables: CREATE TABLE Sales.Cu...

    Display all customers. If a customer has placed any orders, also display the highest..... Tables: CREATE TABLE Sales.Customers ( CustomerId          INT          NOT NULL IDENTITY, CustomerName          NVARCHAR(50) NOT NULL, StreetAddress NVARCHAR(50) NULL, City          NVARCHAR(20) NULL, [State]          NVARCHAR(20) NULL, PostalCode         NVARCHAR(10) NULL, Country          NVARCHAR(20) NULL, Contact          NVARCHAR(50) NULL, Email         NVARCHAR(50) NULL, CONSTRAINT PK_Customers PRIMARY KEY(CustomerId) ); CREATE TABLE HR.Employees ( EmployeeId          INT          NOT NULL IDENTITY, FirstName         NVARCHAR(50) NOT NULL, LastName          NVARCHAR(50) NOT NULL, BirthDate         DATE         NOT NULL, HireDate          DATE         NOT NULL, HomeAddress...

  • Given the following table structure, write the SQL code to display all the first and last...

    Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that begins with the letter 'M! CREATE TABLE Persons Personi int LastName varchar(80). FirstName varchar(80). Address varchar(125). State char(2) Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that does not contain the letter 'S: CREATE TABLE Persons PersonlDint,...

  • SQL Command - Create a view called S LIST that lists the Cardholder Number, last name,...

    SQL Command - Create a view called S LIST that lists the Cardholder Number, last name, first name and due date for all cardholders who have not returned a book. Use the CREATE OR REPLACE VIEW AS ... command. TABLE CARD HOLDERS Cardholder Numberint NOT NULL CONSTRAINT CH PK PRIMARY KEY, First_Name varchar(10) NULL, LastName varchar(15) NULL, Address varchar(20) NULL, varchar(15) NULL, State char(2) NULL, Zip_Code char(5) NULL) City TABLE BOOKS CHECKED OUT Cardholder_Numberint NOT NULL, Book Numberint NOT NULL,...

  • SQL Query Question: I have a database with the tables below, data has also been aded...

    SQL Query Question: I have a database with the tables below, data has also been aded into these tables, I have 2 tasks: 1. Add a column to a relational table POSITIONS to store information about the total number of skills needed by each advertised position. A name of the column is up to you. Assume that no more than 9 skills are needed for each position. Next, use a single UPDATE statement to set the values in the new...

  • Tables: Create table Item(                 ItemId                 char(5) constraint itmid_unique primar

    Tables: Create table Item(                 ItemId                 char(5) constraint itmid_unique primary key,                 Decription           varchar2(30),                 Unitcost               number(7,2)); Create table Customer(                 custID                   char(5) constraint cid.unique primary key,                 custName          varchar2(20),                 address                                varchar2(50)); Create table Orderdata( orderID                char(5) constraint oid_uniq primary key,                 orderdate           date,                 shipdate              date,                 ItemId                  char(5) references Item.ItemId,                 No_of_items     number(4),                 Unitcost               number(7,2),                 Order_total        number(7,2),                 custID                   char(5) references customer.custID); Insert Into Item values(‘A123’,’Pencil’,2.5); Insert Into Item values(‘B123’,’Pen’,15); Insert Into...

  • Create a procedure to update the sales history table following the requirements below. A table creation...

    Create a procedure to update the sales history table following the requirements below. A table creation script is provided below. a) Call the procedure: UPDATE_SALES_HISTORY (The procedure name is important for our scripts to test and grade your code; please do not rename it (otherwise our scripts will not run and your score will be 0). b) The procedure takes 2 parameters: (4-digit-year, 2-digit-month). Both parameters will be numeric, e.g., (2019, 11) will denote 2019 (year) and November (month). The...

  • -- drop tables DROP TABLE REQUEST CASCADE CONSTRAINTS; DROP TABLE FULLORDER CASCADE CONSTRAINTS; DROP TABLE PRODUCT...

    -- drop tables DROP TABLE REQUEST CASCADE CONSTRAINTS; DROP TABLE FULLORDER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; -- create and link tables CREATE TABLE CUSTOMER (    CustomerID   INTEGER,    Name       VARCHAR2(40),    City       VARCHAR2(20),    State       CHAR(2),    Zip       CHAR(5),    CONSTRAINT PK_CUSTOMER        PRIMARY KEY (CustomerID) ); CREATE TABLE PRODUCT (    ProductID   INTEGER,    Description   VARCHAR2(30),    Material   VARCHAR2(20),    Price       NUMBER(5,2),    CONSTRAINT PK_PRODUCT...

  • Sample data is provided for the database for the sales system. Using the sample data, you...

    Sample data is provided for the database for the sales system. Using the sample data, you will determine the entities, key components of the entities, and business rules for the entities. Using the entities and business rules you will then create an ERD. Tasks: 1. For each entity provide the name, description, fields, data type, primary key, and foreign key. 2. For each direct entity type pair, provide the business rules. 3. Provide the ERD. Customer Table Customer ID, Last...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT