我不确定我是否正确使用回滚/提交;有人能够解释如何在python中使用它们吗?
PROCEDURE bookCar( class IN INT, from_date IN DATE, to_date IN DATE, reservation_no OUT INT )
DECLARE
available_car INT;
BEGIN
TRANSACTION
SELECT car_id INTO :available_car
FROM Cars
WHERE class= :class AND booked = FALSE
LIMIT 1;
COMMIT
IF ( :available_car IS NOT NULL ) THEN BEGIN
TRANSACTION
UPDATE Cars
SET booked = TRUE
WHERE car_id = :available_car;
--
SELECT MAX(reservation_no)+1 INTO :reservation_no
FROM Bookings;
--
INSERT INTO Bookings VALUES( :reservation_no, :available_car, :from_date, :to_date );
ROLLBACK
ELSE
COMMIT
END IF;
ROLLBACK
END;
我很感激我能得到的任何帮助,因为我真的很挣扎!谢谢!