MS2 Updated Version V1
This commit is contained in:
parent
f61fdf3741
commit
c90543094d
2 changed files with 44 additions and 19 deletions
|
@ -7,21 +7,25 @@ IS
|
||||||
finalclerkid NUMBER;
|
finalclerkid NUMBER;
|
||||||
maxanzahlcleanings NUMBER;
|
maxanzahlcleanings NUMBER;
|
||||||
BEGIN
|
BEGIN
|
||||||
startMonat := ADD_MONTHS(SYSDATE,-months);
|
IF months > 0 THEN
|
||||||
|
startMonat := ADD_MONTHS(SYSDATE,-months);
|
||||||
|
|
||||||
SELECT CLERKID, Anzahl INTO finalclerkid, maxanzahlcleanings FROM
|
SELECT CLERKID, Anzahl INTO finalclerkid, maxanzahlcleanings FROM
|
||||||
(
|
|
||||||
SELECT DISTINCT CLERKID, COUNT(CLERKID) AS Anzahl
|
|
||||||
From
|
|
||||||
(
|
(
|
||||||
SELECT clcl.CLERKID
|
SELECT DISTINCT CLERKID, COUNT(CLERKID) AS Anzahl
|
||||||
FROM CLEANINGCLERK clcl
|
From
|
||||||
INNER JOIN CLEANINGPLAN clpl ON clcl.CLEANINGPLANID = clpl.CLEANINGPLANID
|
(
|
||||||
WHERE clpl."date" >= startMonat
|
SELECT clcl.CLERKID
|
||||||
)
|
FROM CLEANINGCLERK clcl
|
||||||
GROUP BY CLERKID ORDER BY Anzahl desc
|
INNER JOIN CLEANINGPLAN clpl ON clcl.CLEANINGPLANID = clpl.CLEANINGPLANID
|
||||||
)
|
WHERE clpl."date" >= startMonat
|
||||||
WHERE ROWNUM <= 1;
|
)
|
||||||
|
GROUP BY CLERKID ORDER BY Anzahl desc
|
||||||
|
)
|
||||||
|
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
|
||||||
SELECT arrivalDate INTO cleaningDate FROM BOOKING
|
IF INSERTING OR UPDATING THEN
|
||||||
WHERE BOOKING.BOOKINGID = :NEW.bookingId;
|
SELECT arrivalDate INTO cleaningDate FROM BOOKING
|
||||||
cleaningDate := cleaningDate - 1;
|
WHERE BOOKING.BOOKINGID = :NEW.bookingId;
|
||||||
INSERT INTO CLEANINGPLAN VALUES (cleaningplan_seq.nextval, cleaningDate, 90, :NEW.roomNumber);
|
cleaningDate := cleaningDate - 1;
|
||||||
|
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