Write an anonymous block that places a substitution variable

Assignment Help Database Management System
Reference no: EM13803893

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: EM13803893

Questions Cloud

Wirte essay on anna karenin as polemic and madame bovary : Wirte 3 pages essay for me based on Leo Tolstoy's novel Anna Karenin as Polemic with the novel of Gustave Falubert's Madame Bovary.
Examples of target populations : Review your list of local city and state agencies (or the two agencies you compared) and select a target population. Examples of target populations are the poor, unemployed, children, elderly, people with disabilities, persons with mental illness,..
Verify the values inserted by using a query : Write INSERT statements for adding the following data to the new table: Verify the values inserted by using a query. Display each distinct agency (each agency only once)
Operational efficiency : •You are to succinctly define in your own words the phrases "operational efficiency", "operational effectiveness", "operations strategy" and "operational sustainability"•Further, you are to address "Six Sigma," and comment on its applicability and va..
Write an anonymous block that places a substitution variable : 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
Local electronic store provides customers with walk-in : Q: A local electronic store provides customers with walk-in service to repair their flat screen TVs of various technologies (LCD, LED, Plasma, etc.). When an item arrives, store technicians perform basic tests at the test shop (station 1) and decide ..
Analyze the impact of international policy making : Analyze the impact of international policy making on the current year's budgets and possible impact on future budget line items. (Title this section Implications of Foreign Policy.
Aggregate planning problem for one quarter : Consider the following aggregate planning problem for one quarter: Regular Time Overtime Subcontracting Production capacity/month 1,000 200 150 Production cost/unit $5 $7 $8
List of the human service agencies : Compile a list of the human service agencies in your city or state.

Reviews

Write a Review

 

Database Management System Questions & Answers

  Applying data mining techniques to available data

Applying Data Mining techniques to publically available data produced by both Transpower and the National Institute of Water and Atmospheric Research (NIWA), from which a range of visualizations will be generated.

  Describe discretionary access control

Database security expert to train the database administration team.At the first training session,you ask the trainees to perform the following tasks using Microsoft SQL Server Management Studio. Describe what you expect your trainees to produce.

  Craete the database to be fault tolerant

Explain the thought process of DBA as they craete the database to be fault tolerant. What policies would you suggest to get this goal?

  Write names-e-mail addresses for customers by foreign key

Illustrate all data in each of the four tables. Don't show foreign key columns. Write down the names and e-mail addresses for all customers who have had stove repair which cost more than $50.

  Design an relational model model

Design an Relational Model (RM) model of a database (DB) that will be useful for each of the chosen enterprises and Implement the 2 enterprise relational DBs using either MySQL or SQLite

  Explain relational database design

How would you change the current design and how does your new design address the problems you have identified with the current design.

  Key value of fourth index record on top level

What is the key value of the 4th index record on the top level, assuming each index record points to the record with the highest key value in a block of the next level down?

  Front-end and back-end validation

What are the advantages and disadvantages of front-end and back-end validation and in which specific situations would one technique of validation be preferred over the other?

  Create a local database that will synchronize data

In the prior phase, you started work on some of the application's graphical user interface (GUI). In this assignment, you will add a data entry form to the GUI and create a local database that will synchronize data to the isolated storage containe..

  Advantages of using an object-oriented database

From the e-Activity, select an organization, and explain the advantages and disadvantages of using an object-oriented database and a NoSQL database in its marketplace

  Patients post cardiac bypass surgery

Monitor Renal Outcomes in patients post cardiac bypass surgery?

  Normalize the following relations to 3nf

Do you always have to use the third normal form? Why or why not? What can happen if you do not use the third normal form? Normalize the following relations to 3NF, using the set of functional dependencies listed:

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