Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem: Change a reservationDate: Input the reservation ID and change reservati

ID: 3920804 • Letter: P

Question

Problem: Change a reservationDate: Input the reservation ID and change reservation start and end date, if there is availability in the same room type for the new date interval.

I have attached images of my procedural code, and the output for the procedure and execute statements. I have also attached my select statement and results. I can't seem to figure out what the error is in my code isn't updating the record in the table reservation itself.

I am coding PL/SQL in Oracle SQL Developer.

set serveroutput on CREATE OR REPLACE PROCEDURE change_reservation_date (reservation_id IN varchar2, reserv_start_date IN date, reserv_end date IN date, room type IN varchar2) IS CURSOR reserv cursor IS SELECT reserv_start, reserv end FROM reservation WHERE reservation.room number - room type: reserv_row reserv_cursor rowtype: BEGIN OPEN reserv cursor LOOP FETCH reserv cursor INTO reserv row: EXIT WHEN reserv cursortnotfound; END LOOP: UPDATE reservation SET reserv start reserv start date WHERE reservation. reservation id-reservation id and (reservation. reserv end reserv_end_date) UPDATE reservation SET reserv end-reserv end date WHERE reservation. reservation-id reservation-id and (reservation. reserv end

Explanation / Answer

Hi Sir, you should mention the "COMMIT" statement after all your updates have been done successfully before you exit the Cursor Loop

eg:- UPDATE Reservation Set reserv_start = ....... ; // This is your first update statement

UPDATE Reservation Set reserv_end = ........; // This is your second update statement

COMMIT; // Save the changes that you made via the 2 update stmts in the DB, This was missing

CLOSE reserv_cursor; // Close the Cursor Variable.

Please let me know in case of any clarifications required. Thanks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote