Question
hi, I want you to help me to continue my left problems, I did not know why shows 'no data found' in my SQL code
hi, I want you to help me to continue my left problems, I did not know why shows 'no data found' in my SQL code run. please help me to finish questions 5 6 7 ,8,9.
there is my left questions: and give the correct run screenshots of mt question 5,6,7,8,9...... function of 5, 9........
Fortune Car rentals are developing an automated system through which they wish to keep records of their vehicles, clients and daily reservations.
There are several rules they follow:
1. A client needs to register before they can make reservations. (every client will have client ID)
2. All the cars are registered in the vehicle table (each vehicle has a vehicle ID)
3. Reservation can be done from a start date to end date. An estimate budget is given to the client and the reservation is posted in the reservation table. Make sure end_date is not entered yet. The procedure returns the reservation_Id.
4. Reservation rules are:
A client cannot rent a car if she/he is under the age of 18.
5. When client is returning the car (can pass reservation ID or client ID):
The reservation ID is given.
If a reservation is for more than 10 days, a 10% discount is offered
If the reservation in having Christmas day in between, a 20% discount is offered.
Now calculate the cost and ask for the payment.
If client is not paying, or car is broken by the client, the client is moved to black list table with the reason
6. At the end of every year, the reservation table is emptied out (Leaving the records without end_date)
7. The data is moved to the archieved_reservation
8. Stats are generated and copied to the stats table.
9. The ultimate aim is to answer the following questions:
List all the active bookings for the cars.
List all the details of the clients having the cars rented today.
List all blacklisted clients
How many bookings do we have at Christmas time.
Generate the total revenue generated on a specific vehicle.
here are my current SQL codes:
CREATE TABLE vehicle ( v_id number PRIMARY KEY, v_make VARCHAR2(50), v_model VARCHAR2(50), cost_pday number ); create table client( c_id number primary key, f_name varchar2(50), l_name varchar2(50), dob date, city varchar(50), gender char(10) ); create table ar_res ( res_id number primary key, s_date date, e_date date, c_id number, v_id number, t_cost number, add_by varchar2(50), add_date date ); create table b_list ( c_id number primary key, f_name varchar2(50), l_name varchar2(50), dob date, city varchar2(50), gender char(10), reason varchar2(50), add_by varchar2(50), add_date date ); create table stats ( year number, c_id number, age number, gender char(10), tol_res number, tol_days_res number, tol_cost_res number ); create table reservations( res_id number primary key, s_date date, e_date date, c_id number, v_id number, t_cost number, constraint fk_c_id foreign key (C_ID) references CLIENT(C_ID), constraint fk_v_id foreign key (V_ID) references VEHICLE(V_ID) );
CREATE PROCEDURE add_client(
a_fname in varchar2, a_lname in varchar2, a_dob in DATE, a_city in varchar2, a_gender in char ) is l_c_id number; begin select NVL(MAX(c_id), 0)+1 into l_c_id from client; insert into client (c_id, f_name, l_name, dob, city,gender) values (l_c_id, a_fname, a_lname, a_dob, a_city, a_gender);
DBMS_output.put_line('client registered successfully with id'||l_c_id); end;
declare l_c_id number; begin add_client('alice', 'le', to_date('1998-09-08', 'yyyy-mm-dd'),'Kamloops','male'); end; select*from client;
CREATE PROCEDURE make_reservations(
a_s_date in date, a_e_date in date, a_c_id in number, a_v_id in number, a_e_budget in number, p_res_id out number ) is l_res_id number; l_dob date; begin select dob into l_dob from client where c_id= a_c_id; if months_between(sysdate, l_dob)<216 then raise_application_error(-20001, 'client age is under 18 age'); end if;
select NVL(MAX(res_id), 0)+1 into l_res_id from reservations; insert into reservations (res_id, s_date, e_date,c_id, v_id, t_cost) values (l_res_id, a_s_date, null, a_c_id, a_v_id, a_e_budget*(a_e_date - a_s_date+1));
p_res_id:=l_res_id;
DBMS_output.put_line('reservations registered successfully with id'||l_res_id); end;
declare l_res_id number; BEGIN make_reservations( a_s_date=> to_date('1999-09-08', 'YYYY-MM-DD'), a_e_date=> to_date('2003-09-07', 'YYYY-MM-DD'), a_c_id=>2341, a_v_id=>2566, a_e_budget=> 100, p_res_id=> l_res_id ); end; select* from reservations;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started