sgd-praktikum/SQL/TestTrigger.sql

54 lines
2.3 KiB
MySQL
Raw Normal View History

2023-05-25 16:26:44 +02:00
2023-06-03 10:17:20 +02:00
-- Automatisch Cleaningplan erstellen
2023-05-25 16:26:44 +02:00
INSERT INTO BOOKING VALUES (444, TO_DATE('2023-09-07', 'YYYY-MM-DD'), TO_DATE('2023-10-01', 'YYYY-MM-DD'), 65, 'No Pension', 0, 15);
INSERT INTO BOOKINGROOM VALUES (444, 8);
2023-05-30 08:46:57 +02:00
SELECT * FROM CLEANINGPLAN WHERE "date" = TO_DATE('2023-09-06', 'YYYY-MM-DD');
ROLLBACK;
2023-05-25 16:26:44 +02:00
2023-06-03 10:17:20 +02:00
-- Automatisch Cleaningplan erstellen und löschen
INSERT INTO BOOKING VALUES (444, TO_DATE('2023-09-07', 'YYYY-MM-DD'), TO_DATE('2023-10-01', 'YYYY-MM-DD'), 65, 'No Pension', 0, 15);
INSERT INTO BOOKINGROOM VALUES (444, 8);
SELECT * FROM CLEANINGPLAN WHERE "date" = TO_DATE('2023-09-06', 'YYYY-MM-DD');
DELETE FROM BOOKINGROOM WHERE bookingID = 444;
SELECT * FROM CLEANINGPLAN WHERE "date" = TO_DATE('2023-09-06', 'YYYY-MM-DD');
ROLLBACK;
2023-05-25 16:26:44 +02:00
-- Cleaningplan kann nicht erstellt werden
INSERT INTO BOOKING VALUES (555, TO_DATE('2023-09-03', 'YYYY-MM-DD'), TO_DATE('2023-09-05', 'YYYY-MM-DD'), 65, 'No Pension', 0, 15);
INSERT INTO BOOKING VALUES (556, TO_DATE('2023-09-06', 'YYYY-MM-DD'), TO_DATE('2023-10-01', 'YYYY-MM-DD'), 65, 'No Pension', 0, 15);
INSERT INTO BOOKINGROOM VALUES (555, 8);
INSERT INTO BOOKINGROOM VALUES (556, 8);
2023-05-30 08:46:57 +02:00
SELECT * FROM CLEANINGPLAN WHERE "date" = TO_DATE('2023-09-05', 'YYYY-MM-DD');
ROLLBACK;
2023-05-25 16:26:44 +02:00
-- Cleaningplan kann nicht erstellt werden
INSERT INTO BOOKING VALUES (888, TO_DATE('2023-09-03', 'YYYY-MM-DD'), TO_DATE('2023-09-05', 'YYYY-MM-DD'), 65, 'No Pension', 0, 15);
INSERT INTO BOOKINGROOM VALUES (888, 8);
INSERT INTO CLEANINGPLAN VALUES (cleaningplan_seq.nextval, TO_DATE('2023-09-04', 'YYYY-MM-DD'), 240, 8);
2023-05-30 08:46:57 +02:00
ROLLBACK;
2023-05-25 16:26:44 +02:00
-- Cleaningplan wird erfolgreich gebucht
INSERT INTO CLEANINGPLAN VALUES (cleaningplan_seq.nextval, TO_DATE('2023-11-09', 'YYYY-MM-DD'), 240, 8);
2023-05-30 08:46:57 +02:00
SELECT * FROM CLEANINGPLAN WHERE "date" = TO_DATE('2023-11-09', 'YYYY-MM-DD');
ROLLBACK;
2023-05-25 16:26:44 +02:00
-- Gesamtpreise werden angezeigt
INSERT INTO BOOKING VALUES (234, TO_DATE('2023-09-03', 'YYYY-MM-DD'), TO_DATE('2023-09-05', 'YYYY-MM-DD'), 65, 'No Pension', 0, 15);
INSERT INTO BOOKING VALUES (456, TO_DATE('2023-09-06', 'YYYY-MM-DD'), TO_DATE('2023-10-01', 'YYYY-MM-DD'), 10, 'No Pension', 0, 15);
2023-06-03 10:27:02 +02:00
UPDATE BOOKING SET COST = 5 WHERE BOOKINGID = 456;
INSERT INTO BOOKING VALUES (789, TO_DATE('2023-09-06', 'YYYY-MM-DD'), TO_DATE('2023-09-06', 'YYYY-MM-DD'), 10, 'No Pension', 0, 15);
DELETE FROM BOOKING WHERE BOOKINGID = 234;
2023-05-30 08:46:57 +02:00
ROLLBACK;