Question
Oracle SQL Question Tables: CREATE TABLE VEHICLE_19 (V_ID CHAR(5) PRIMARY KEY , V_MODEL VARCHAR2(15), V_MAKE CHAR(4), COST_PER_DAY NUMBER(7,2)); INSERT INTO VEHICLE_19 VALUES ('V1001', 'Tata Sierra',
Oracle SQL Question
Tables:
CREATE TABLE VEHICLE_19 (V_ID CHAR(5) PRIMARY KEY , V_MODEL VARCHAR2(15), V_MAKE CHAR(4), COST_PER_DAY NUMBER(7,2));
INSERT INTO VEHICLE_19 VALUES ('V1001', 'Tata Sierra', '2011',37.50); INSERT INTO VEHICLE_19 VALUES ('V1002', 'Honda CRV', '2016',47.50); INSERT INTO VEHICLE_19 VALUES ('V1003', 'Mercedez Benz', '2011',117.50); INSERT INTO VEHICLE_19 VALUES ('V1004', 'Ford Focus', '2011',87.50); INSERT INTO VEHICLE_19 VALUES ('V1005', 'Dodge Dakota', '2013',87.00);
Create table CLIENT_19 (C_ID CHAR(10) PRIMARY KEY, F_NAME VARCHAR2(25), L_NAME VARCHAR2(25), DOB DATE, CITY VARCHAR2(15), GENDER CHAR(1) CHECK (GENDER IN (NULL, 'M','F')));
INSERT INTO CLIENT_19 VALUES ('C00000001','Mike','Thomas',to_date('1998-12-20','yyyy-mm-dd'), 'Kamloops','M'); INSERT INTO CLIENT_19 VALUES ('C00000002','Andrew','Thessen',to_date('1988-08-20','yyyy-mm-dd'), 'Williams Lake','M');
create table RESERVATION_19 (R_ID NUMBER PRIMARY KEY, START_DATE DATE, END_DATE DATE, C_ID CHAR(10) REFERENCES CLIENT_19(C_ID), V_ID CHAR(5) REFERENCES VEHICLE_19(V_ID) , TOTAL_COST NUMBER(9,2));
INSERT INTO RESERVATION_19 VALUES (1, TO_DATE('12-01-2019','DD-MM-YY'), TO_DATE('15-01-2019','DD-MM-YY'), 'C00000001', 'V1003',352.50); INSERT INTO RESERVATION_19 VALUES (2, TO_DATE('2-01-2019','DD-MM-YY'), TO_DATE('6-01-2019','DD-MM-YY'), 'C00000002', 'V1001',150.00); INSERT INTO RESERVATION_19 VALUES (3, TO_DATE('10-10-2018','DD-MM-YY'), TO_DATE('12-10-2018','DD-MM-YY'), 'C00000001', 'V1004',150.00);
Question:
Archiving data (Stored Procedure)
Create a stored procedure to archive the reservation data. The archived procedure is executed by the DBA on the first day of a new year. This procedure has no input parameters and displays message total # reservations archived. The archiving procedure adds the old (previous year) reservations to the ARCHIVED_RESERVATION table and deletes the old reservations from the RESERVATION table.
Thanks
CLIENT C ID F NAME L NAME DOB CITY GENDER VEHICLE RESERVATION V ID V MODEL V MAKE COST PER DAY R ID START DATE END DATE C ID V ID TOTAL COST ARCHIVED RESERVATION R ID START DATE END DATE C ID V ID TOTAL COST ADDED BY ADDED DATE STATS YEAR C ID AGE GENDER TOT RESERVATIONS TOT DAYS OF RESERVATIONS TOT COST OF RESERVATIONS BLACK_LIST C ID F NAME L NAME DOB CITY GENDER REASON ADDED BY ADDED DATEStep 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