Create local variable that inherits structure of car table

Assignment Help Database Management System
Reference no: EM13801812

Question 1:

Write an anonymous block that places a substitution variable (&) into a local variable of type varchar2. You will need to convert the types and round them to nearest tens unit.  For example 84.4555 would be 84.5. You should check the value entered in the local variable and output different messages depending on the value provided.  The anonymous block is a simple grade calculator with the following rules.

 

If value less than 44.5 output the following message "Resulting Grade for VALUE marks is 'F'"

 

If value is between 44.5 and 49.4 output the following message "Resulting Grade for VALUE marks is 'IS'"

 

If value is between 49.5 and 64.4 output the following message "Resulting Grade for VALUE marks is 'C'"

 

If value between 64.5 and 74.4 output the following message "Resulting Grade for VALUE marks is 'B'"

 

If value is between 74.5 and 84.4 output the following message "Resulting Grade for VALUE marks is 'A'"

 

If value is between 84.5 and 100 output the following message "Resulting Grade for VALUE marks is 'HD'"

 

If the value does not fall in the range of 0 - 100 print an error message "ONLY MARKS BETWEEN 0 AND 100 ACCEPTED)"

 

Question 2:

 

Write an anonymous block that meets the following specification:

 

  1. Using an explicit cursor, retrieve each row from the i_car table.
  2. Create a local variable that inherits the structure of the i_car table (using %ROWTYPE attribute). Place each row returned into this variable.
  3. Using an implicit cursor, calculate the number of bookings that belong to each car.
  4. Display the car registration, car group name, model name and the number of bookings for all the cars that have two or more bookings.
  5. If the car has no bookings sum up the number of cars without bookings.
  6. At the end of the run display a message "There are VALUE cars that have no bookings recorded".

 

Question 3:

Create a bound/host (or global) variable named G_NEWCOST.

 

Write an anonymous block that declares two local variables: A3_COST and B3_COST. The data types of these two variables should be the same as the data type of the column cost in i_car table. Also declare a constant called DEPRECIATION with value 15.25 to be used for deprecation calculation.

 

In your BEGIN section, write two SELECT queries to obtain value of the cost column where car_group_name is 'A3' and 'B3' and assign the corresponding values to A3_COST and B3_COST variables.

 

Now use the IF-THEN statement to compare the two variables to find out which one has a highest value. Calculate the new cost by using constant DEPRECIATION to calculate the new value (total cost * (100 - DEPRICATION)) to the higher value and assign the new value to bound/host variable G_NEWCOST.

 

Display a message in the following format from your code block:  "The car group CARGROUP has total cost of $TOTALCOST.XX and has been depreciated to $G_NEWCOST.XX"

 

The CARGROUP should display the highest car group (A3 or B3 depending on values).

 

The TOTALCOST will be the total calculated in the SELECT query statement.

 

G_NEWCOST will be the derived value after decreasing the cost with the DEPRECIATION value.  Format the G_NEWCOST value to 2 decimal places. 

 

The XX represent the decimal places in the format.

 

Using the PRINT command, output the value in the host variable (G_NEWCOST) after the anonymous block has run.

 

Question 4:

Write a PL/SQL solution that displays the registration and the maximum and the minimum miles travelled by a car during the rental period for all the bookings where the booking has been paid for.

The output from the anonymous block will be two messages.  One message will display the information for the maximum miles driven and one for the minimum miles driven in the following format.

 

"The maximum miles driven was MAXIMUM by car REGISTRATION over DAYS day's"

 

"The minimum miles driven was MINIMUM by car REGISTRATION over DAYS day's"

 

Where MAXIMUM is the maximum miles calculated from the bookings table.

 

MINIMUM is the minimum miles calculated in the bookings table.

 

DAYS is the rental_period for the maximum and minimum miles travelled in the booking table.

 

 

Your program must use at least one explicit cursor and must NOT use any aggregate functions, for example SUM, MAX, COUNT, etc.

Reference no: EM13801812

Questions Cloud

Digital rights and intellectual property : Discussion Activity #6:  Digital Rights and Intellectual Property  Course Objective: Critically assess the digital rights management issues that exist in cyberspace. The class discusses digital rights management and its impact on cybersecurity polic..
Ethnicity and learning theory : Ethnicity and Learning Theory
Create a collection in mongodb : Create a Collection in MongoDB. You should have a minimum of 10 documents. You will create the Collection using the IBM Bluemix.
Identify mur critical success factors in the us and then dis : Review Lavendary Café: The China Chellenge (HBS 4357 2011) case QUESTIONS:1. What is a Multi-unit Restaurant (MuR) Business? How big is it? Is it a consolidated orfragmented industry? What are its economics (use the Porter's Model to evaluate profita..
Create local variable that inherits structure of car table : Using an explicit cursor, retrieve each row from the i_car table. Create a local variable that inherits the structure of the i_car table (using %ROWTYPE attribute). Place each row returned into this variable
Has martin breached any law : Is Swimmingpool Co liable for Martin's actions? On what basis in law would this be the case - can the company claim they are not liable for Martin because he has not followed instructions? Explain.
Advanced pathophysiology across the lifespan : Advanced Pathophysiology Across the Lifespan
Describe your supervisory experience in the training area. : Describe your supervisory experience in the training area. Highlight your work experience in the design, development, and delivery of technical training in both OLT and ILT formats.
Calculate thephat the equivalence point in titrating : A) Calculate thepHat the equivalence point in titrating 0.120Msolutions of each of the following with 8.0×10-2MNaOH. hydrobromic acid (HBr) chlorous acid (HClO2)

Reviews

Write a Review

Database Management System Questions & Answers

  Part 1 - reportwrite a 2000-word report that describes a

part 1 - reportwrite a 2000-word report that describes a suitable methodology from the literature for the purpose of

  Identify three potential users and design subschema for each

Identify three potential users and design a subschema for each. Justify your design by explaining why each user needs access to that data element.

  If you cannot capture some constraints explain why

Consider the university database from Exercise 2.3 and the ER dia-gram you designed. Write SQL statements to create the corresponding relations and capture as many of the constraints as possible. If you cannot capture some constraints, explain why.

  Design a database - what is the purpose of your database

Design a database, a database planner should spend a considerable amount of time thinking about what kind of information will be included in the database and how it will be organized.

  1 what is meant by data independence explain your answer2

1. what is meant by data independence? explain your answer.2. identify two benefits of separating application software

  Create data warehouse sections including computers-dvds

Create a data warehouse for electronics store chain. The chain has 20 stores in 5 cities. Each store has different sections including computers, DVDs, TVs, audio, home appliances etc.

  Using join sort results alphabetically by customer name

Using Join, list the items each customer ordered where the billing_price was lower than the item price (item, billing_price, and price). Sort the results alphabetically by customer name.

  Evaluate the success wellco and pharmacare shareholders

Evaluate the success WellCo and PharmaCARE shareholders

  Demodulator circuits and amplitude modulator

Explain how much the modulating signal power is required to generate 100 percent modulation? What is the approximate center frequency of filter required to pass the lower sideband?

  Write long term problems when constraints are implemented

Why are these so significant yet so frequently ignored by developers? Write the long term problems when these constraints are not implemented? "

  Print a list of classes that mary calahan will be taking

Print a list of classes that Mary Calahan will be taking and Make a class list for Ocean Ecosytems. Include the instructors name

  Create a database to control its local libraries

A county wishes to create a database to control its local libraries. Each library has a number of employees, one of whom is designated as the manager of the library and is responsible for supervising employees and the general day-to-day management..

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