MS2 Updated Version V1
This commit is contained in:
parent
f61fdf3741
commit
c90543094d
2 changed files with 44 additions and 19 deletions
|
@ -7,6 +7,7 @@ IS
|
||||||
finalclerkid NUMBER;
|
finalclerkid NUMBER;
|
||||||
maxanzahlcleanings NUMBER;
|
maxanzahlcleanings NUMBER;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
IF months > 0 THEN
|
||||||
startMonat := ADD_MONTHS(SYSDATE,-months);
|
startMonat := ADD_MONTHS(SYSDATE,-months);
|
||||||
|
|
||||||
SELECT CLERKID, Anzahl INTO finalclerkid, maxanzahlcleanings FROM
|
SELECT CLERKID, Anzahl INTO finalclerkid, maxanzahlcleanings FROM
|
||||||
|
@ -22,6 +23,9 @@ BEGIN
|
||||||
GROUP BY CLERKID ORDER BY Anzahl desc
|
GROUP BY CLERKID ORDER BY Anzahl desc
|
||||||
)
|
)
|
||||||
WHERE ROWNUM <= 1;
|
WHERE ROWNUM <= 1;
|
||||||
|
ELSE
|
||||||
|
RAISE_APPLICATION_ERROR(-20111, 'Nur Positive Werte (>0) sind als Eingabe erlaubt');
|
||||||
|
END IF;
|
||||||
|
|
||||||
return finalclerkid;
|
return finalclerkid;
|
||||||
END;
|
END;
|
||||||
|
@ -56,16 +60,24 @@ BEGIN
|
||||||
END rooms;
|
END rooms;
|
||||||
|
|
||||||
CREATE OR REPLACE TRIGGER booking_created
|
CREATE OR REPLACE TRIGGER booking_created
|
||||||
BEFORE INSERT OR UPDATE
|
BEFORE INSERT OR UPDATE OR DELETE
|
||||||
ON BOOKINGROOM
|
ON BOOKINGROOM
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
DECLARE
|
DECLARE
|
||||||
cleaningDate DATE;
|
cleaningDate DATE;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
IF INSERTING OR UPDATING THEN
|
||||||
SELECT arrivalDate INTO cleaningDate FROM BOOKING
|
SELECT arrivalDate INTO cleaningDate FROM BOOKING
|
||||||
WHERE BOOKING.BOOKINGID = :NEW.bookingId;
|
WHERE BOOKING.BOOKINGID = :NEW.bookingId;
|
||||||
cleaningDate := cleaningDate - 1;
|
cleaningDate := cleaningDate - 1;
|
||||||
INSERT INTO CLEANINGPLAN VALUES (cleaningplan_seq.nextval, cleaningDate, 90, :NEW.roomNumber);
|
INSERT INTO CLEANINGPLAN VALUES (cleaningplan_seq.nextval, cleaningDate, 90, :NEW.roomNumber);
|
||||||
|
ELSIF DELETING THEN
|
||||||
|
SELECT arrivalDate INTO cleaningDate FROM BOOKING
|
||||||
|
WHERE BOOKING.BOOKINGID = :OLD.bookingId;
|
||||||
|
cleaningDate := cleaningDate - 1;
|
||||||
|
DELETE FROM CLEANINGPLAN
|
||||||
|
WHERE "date" = cleaningDate AND :OLD.roomNumber = CLEANINGPLAN.ROOMNUMBER;
|
||||||
|
END IF;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE OR REPLACE TRIGGER cleaning_while_booked
|
CREATE OR REPLACE TRIGGER cleaning_while_booked
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
-- Automatisch Cleaningplan generieren
|
-- Automatisch Cleaningplan erstellen
|
||||||
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 BOOKING VALUES (444, TO_DATE('2023-09-07', 'YYYY-MM-DD'), TO_DATE('2023-10-01', 'YYYY-MM-DD'), 65, 'No Pension', 0, 15);
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,19 @@ INSERT INTO BOOKINGROOM VALUES (444, 8);
|
||||||
SELECT * FROM CLEANINGPLAN WHERE "date" = TO_DATE('2023-09-06', 'YYYY-MM-DD');
|
SELECT * FROM CLEANINGPLAN WHERE "date" = TO_DATE('2023-09-06', 'YYYY-MM-DD');
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
|
-- 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;
|
||||||
|
|
||||||
-- Cleaningplan kann nicht erstellt werden
|
-- 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 (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 BOOKING VALUES (556, TO_DATE('2023-09-06', 'YYYY-MM-DD'), TO_DATE('2023-10-01', 'YYYY-MM-DD'), 65, 'No Pension', 0, 15);
|
||||||
|
|
Loading…
Reference in a new issue