CREATE PROCEDURE available_rooms(
hotelname_param VARCHAR(45),
date_param DATE)
BEGIN
IF date_param IS NULL THEN -- if the booking date is null
SIGNAL SQLSTATE '22003' -- signalling error
SET MESSAGE_TEXT = 'the booing date should not be null',
MYSQL_ERRNO = 1264;
END IF;
SELECT h.Hotel_id AS HotelID,hotelname_param AS HotelName,((h.Floor_count) * (h.Roomsperfloor)) AS TotalRooms,
g.Guest_firstname AS Guestname,b.Room_count AS RoomsBooked,
(((h.Floor_count) * (h.Roomsperfloor)) - b.Room_count) AS AvailableRooms
FROM hotel h
JOIN guests g ON h.Hotel_id = g.Hotel_id
JOIN booking b ON g.Guest_id = b.Guest_id
WHERE b.BookingDate = date_param;
END
CALL available_rooms('Grand Central Inn','2018-01-11')
当我调用该过程时,其显示输出为THIS 因此,第一行的可用房间应该用于下一行计算,但我无法得到它。任何人都可以帮助我