Program to compute the sum

Assignment Help Database Management System
Reference no: EM131247334

Suppose you have created tables in assignment.

Please write an anonymous PL/SQL program for each the following problems.

You can use the attached SQL statements to create the tables.

Problem 1: Write an anonymous PL/SQL program to compute the sum of 1, 3, 5, 7, 9. You must use a loop. Tip: consider how to update your loop variable.

Problem 2: Use an implicit cursor to print out the name of category of product with pid = 1. Please handle exceptions. Note that your code needs to work for any data in the database (e.g., you cannot manually look up category id).

Problem 3: Use an explicit cursor to print out the names of products under the category TV and with screen size (the feature size) of at least 42 inches.

Sample code to create the tables.

drop table review;
drop table product_feature;
drop table product;
drop table feature;
drop table category;
drop table users;

create table users(
userid integer,
uname varchar(50),
password varchar(50),
primary key (userid));

create table category(
cid integer,
cname varchar(50),
primary key (cid));

create table feature (
fid integer,
fname varchar(50),
primary key (fid));

create table product (
pid integer,
cid integer,
pname varchar(50),
brand varchar(50),
price number,
primary key(pid),
foreign key (cid) references category(cid)
);

create table product_feature(
pid integer,
fid integer,
fvalue number,
primary key(pid,fid),
foreign key(pid) references product,
foreign key(fid) references feature);

create table review(
rid integer,
userid integer,
pid integer,
rdate date,
score integer,
rcomment varchar(200),
primary key(rid),
foreign key (userid) references users(userid),
foreign key (pid) references product(pid)
);

----
insert into users values (1,'user1','xyz0376');
insert into users values (2,'user2','87ujh6');
insert into users values (3,'user3','po954jn');

---------
insert into category values(1,'TV');
insert into category values(2,'Cell Phone');
insert into category values(3,'Laptop');

-------
-- size represents screen size in inches
insert into feature values(1,'size');
insert into feature values(2,'weight');
insert into feature values(3,'memory');
insert into feature values(4,'harddisk');
insert into feature values(5,'storage');

--------------
insert into product values(1,1,'Vizio M65-C1','Vizio',1500);
insert into product values(2,1,'TCL 40FS3800','TCL',250);
insert into product values(3,2,'Apple iPhone 6 Plus','Apple',874);
insert into product values(4,2,'Samsung Galaxy S7 Edge','Samsung',769);
insert into product values(5,3,'Apple MacBook MLHE2LL/A','Apple',1200);
insert into product values(6,3,'Dell XPS 13', 'Dell',999);

----------
insert into product_feature values(1,1,65);
insert into product_feature values(1,2,67);
insert into product_feature values(2,1,40);
insert into product_feature values(2,2,16);
insert into product_feature values(3,1,5.5);
insert into product_feature values(3,5,64);
insert into product_feature values(4,1,5.5);
insert into product_feature values(4,5,32);
insert into product_feature values(5,1,12);
insert into product_feature values(5,2,3.2);
insert into product_feature values(5,3,8);
insert into product_feature values(5,4,256);
insert into product_feature values(6,1,13);
insert into product_feature values(6,2,2.9);
insert into product_feature values(6,3,8);
insert into product_feature values(6,4,128);
-------
insert into review values(1,1,1,date '2016-1-1',5.0,'great price for screen size');
insert into review values(2,2,1,date '2016-1-1',5.0,null);
insert into review values(3,3,1,date '2016-8-1',4.0,'good quality picture');
insert into review values(4,1,2,date '2016-5-12',3.0,'too small for me');
insert into review values(5,2,2,date '2016-6-1',5.0,null);
insert into review values(6,3,2,date '2016-8-12',5.0,'cheap but very good quality');

insert into review values(7,1,3,date '2016-6-12',5.0,'screen size, battery life are great');
insert into review values(8,2,4,date '2016-6-1',5.0,null);
insert into review values(9,3,4,date '2016-8-12',3.0,'not enough storage');

insert into review values(10,1,5,date '2016-7-12',5.0,'large flash drive, sharp image');
insert into review values(11,2,5,date '2016-8-1',5.0,null);
insert into review values(12,3,6,date '2016-8-30',4.0,'good product, storage a bit small');

commit;

Verified Expert

The assignment was based on programming in PL/SQL. It contains three questions based on anonymous PL/SQL, implicit and explicit cursor. The code was executed using ORACLE express edition.

Reference no: EM131247334

Questions Cloud

Businesses merely maximize shareholder wealth : Should businesses attempt to solve societal ills, or should businesses merely maximize shareholder wealth? Some individuals argue that the purpose of a business is to make a profit, and maximize shareholder wealth, while others argue that a busine..
Is this inconsistent with capital market efficiency : Empirical evidence indicates that mutual funds that have abnormal returns in a given year are successful in attracting abnormally large numbers of new investors the following year. Is this inconsistent with capital market efficiency?
Should electric or gas forklift trucks purchased by ramsden : Ramsden will apply a 10% discount factor for analysis of the electric trucks and a 2% differential to the gas trucks owing to their higher operating risks. The applicable tax rate is 40%. Should electric or gas forklift trucks be purchased by Rams..
Explain in detail the scope of the public health policy : Briefly describe the public health problem and the policy that addresses the problem. Examine the nature and magnitude of the problem and the people who are affected. Explain in detail the scope of the public health policy. Be sure to provide specifi..
Program to compute the sum : Write an anonymous PL/SQL program to compute the sum of 1, 3, 5, 7, 9. You must use a loop. Tip: consider how to update your loop variable - Write an anonymous PL/SQL program
Which project has greater npv : Note that the cash outflows of Project B have higher variance than those of Project A. Which project has greater NPV? Show your work and explain your reasoning.
What is the effects of counseling on the children of parents : Identify at least one example for each of the following topics that you plan to use for your research proposal due on : What is the effects of counseling on the children of parents who have a substance abuse issue?
Types of stores and other distribution channels : Give 400 words specifically on the Distribution (where sold, types of stores and other distribution channels [including any use of e-commerce], extent of availability, etc of the Apple iPhone.
Explain critical thinking : Provide an example from your personal experience of critical thinking applied to a business decision.Discuss the importance and benefits of using critical thinking.Relate the importance and benefits of critical thinking to the example provided.Dis..

Reviews

Write a Review

Database Management System Questions & Answers

  Write a sql query to display order id and order date

Write a SQL query to display order ID and order date for all the orders made by customers in the territory of Southwest (use WHERE command to join tables). Use sub-query technique to write a SQL query to display order ID and order date for all the..

  Why would you choose a database system instead of simply

Why would you choose a database system instead of simply storing data in operating system files? When would it make sense not to use a database system?

  What type of failure is this and how would it be resolved

A technician accidentally drops screw into the server case and shorts out the motherboard of the server that is running you Oracle database (the database is running at the time of the incident). What type of failure is this and how would it be res..

  What relationships exist between the data

In what ways would a DBMS help this organization? What data can you identify that needs to be represented in the database? What relationships exist between the data? What queries do you think are required?

  Design the class billtype with data members

Design the class doctorType, inherited from the class personType, defined in Chapter 12, with an additional data member to store a doctor's speciality.

  Find the sids of suppliers who supply every part

Find the sids of suppliers who supply every part. Find the sids of suppliers who supply every red part. Find the sids of suppliers who supply every red or green part.

  Create an xy plot of ecg vs. time

Create an XY plot of ECG vs. time, and place the plot on the Plots worksheet. Give the plot an appropriate title and labels for axes, and adjust various parameters of the plot to make it look pleasing and professional. Resize it to approximately..

  Digitalx has been operating a chain of retail stores

digitalx has been operating a chain of retail stores selling cds dvds and games for a number of years. recently they

  What functionality the screen will provide

Look at the advantages and disadvantages for each approach.Provide a description of what functionality the screen will provide. What can the user do with this screen?

  Write a memorandum to sam jones

Write a memorandum to Sam Jones (CIO) and present your research findings. Your memorandum should be no longer than 500 words.

  Oracle has many features for managing and tracking users we

oracle has many features for managing and tracking users. we have discussed user accounts with username password

  United broke artists (uba) is a broker

United Broke Artists (UBA) is a broker for not-so-famous artists. UBA maintains a small database to track painters, paintings, and galleries. A painting is created by a particular artist and then exhibited in a particular gallery

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