Write a stored procedure that displays the contact details


Implement the following tasks using ORACLE SQL*Plus.

Download the file GHRSchema.sql from the LMS site and run it on ORACLE SQL*Plus. This file contains all the CREATE and INSERT statements you will need for this assignment.

To run the file, issue the following command: @D:\dbf\GHRSchema.sql

NOTE: YOU DO NOT NEED TO INSERT MORE DATA INTO THE TABLES.

The list of tables available for this assignment is the following:

CLIENT (ClientNo, Name, Sex, DOB, Address, Phone, Email, Occupation, MaritalStatus, Spouse, Anniversary)
CCONDITION (ClientNo, Condition)
RESERVATION (ResNo, ResDate, NoOfGuests, StartDate, EndDate,
ClientNo, Status)
ACTIVITY (ActivityID, ActName, ActDescription, ActRate, RiskLevel) OUTDOOR_ACTIVITY (ActivityID)
INDOOR_ACTIVITY (ActivityID, Location, OpeningHours) ACCOMMODATION (RoomNo, LevelNo, AccStatus, ConnectedRoomNo,
AccTypeID)
ACCOMMODATION_TYPE (AccTypeID, AccTypeName, AccTypeRate, NoOfBeds) EQUIPMENT (EquipmentID, EquipName, Stock, NextInspection) SUPPLIER (BillerCode, BusinessName, ContactPerson, Phone)
SUPPLIES (EquipmentID, BillerCode) USES_EQUIPMENT (ActivityID, EquipmentID) CLIENT_PREFERENCE (ClientNo, ActivityID) RESERVATION_ACCOMMODATION (ResNo, RoomNo)
ACTIVITY_SUPERVISOR (SupervisorID)
OUTDOOR_INSTRUCTOR (InstructorID, InstrName, InstrPhone,
SupervisorID)
IFIELD (InstructorID, Field)
MASSEUSE (MasseuseID, MassName, MassPhone, Area, SupervisorID) SWIMMING_INSTRUCTOR (SwimmerID, SwimName, SwimPhone, SupervisorID) SUPERVISION (ResNo, ActivityID, SupervisorID, Day, Time)

NOTE: PK is printed underlined and FK is printed italic in italics.

Task 1

Using the tables provided above, provide SQL statements for the following queries.

a. Display the name of the client who has made the most reservations with Getaway Holidays.

b. Display the name of the client who has booked the reservation for the longest period.

c. Display the Room no, Room type, Room rate and No of guests for the reservation made by client(s) having last name "Perez".

d. Display the Name of the equipment and the name of their suppliers (if any) for the outdoor activities with high risk level.

e. Display the details of those reservation that contains a minimum of one set of connected rooms.

f. Display the name of the outdoor instructor who has the most duties as an activity supervisor.

g. Display the name, address and phone number for the clients who has not made any reservations for the past two months. (Name should be displayed in alphabetical order).

h. For each reservation, display the total income coming from activities & total income coming from accommodations along with the reservation number. (Do not consider the discount schemes but consider every reservation even if it does not have any of the costs associated with it).

i. Display the reservations (Reservation number and duration) whose duration is greater than the average duration of reservations.

j. Display the top two most popular activities across all reservations.

Task 2

Provide the implementation of the following stored procedures and function. For submission, please include both the PL/SQL code and an execute procedure/SQL statement to demonstrate the functionality.

a. Write a stored procedure that displays the contact details of clients who does not have any heart conditions or Acrophobia. The resort wants to promote a new outdoor activity to them.

b. Write a stored function that uses the activity ID and date as input and returns the Name of the supervisor assigned for that day.

c. Write a stored procedure that accepts a particular reservation number as input, and as output displays the total layout of the trip in terms of outdoor and indoor activities along with the name of the client and the name of the activity supervisor assigned for each of the activity. (NOTE: this stored procedure should use the function created in Task 2b)

Task 3

Provide the implementation of the following triggers. For submission, please include both the PL/SQL code and an insert statement to demonstrate the trigger functionality.

a. A trigger which automatically raises an error whenever a client with Aqua phobia selects Rafting as a preferred outdoor activity.

b. A trigger that automatically calculates and stores in a separate table called "Reservation_room_expense" the reservation number and the due amount for accommodations for each record number. (Consider the 5% discount on room prices if the trip consists of more than 5 days).

Solution Preview :

Prepared by a verified Expert
PL-SQL Programming: Write a stored procedure that displays the contact details
Reference No:- TGS02346186

Now Priced at $25 (50% Discount)

Recommended (94%)

Rated (4.6/5)