First, this should be implement in the Oracle DBMS but I have no access to it so I have no way to try it.
I have the following query to create:
A flight attendant working at your airline requests day off on the 21st of November, they usually cover the 12 to 22 shift, check the employee’s schedules to make sure someone is covering the same working hours in order to determine if their day off can be given, if not then update working hours of an employee finishing at 12 so they do a double shift to make sure 24 hours are covered with the day off taken.
Relevant info: I have an entity EMPLOYEE that has a relationship with a weak entity SCHEDULE which has the attributes "Day", "StartTime", "EndTime"
This is my first time using the IF statement and this is my attempt:
IF( SELECT StartTime, EndTime
FROM SCHEDULE S
WHERE S.StartTime<=12 AND S.EndTime>=22 AND DAY="21 November") != NULL
want this part to be empty or return something like success*
ELSE
UPDATE SCHEDULE
SET EndTime=22
WHERE EndTime=12 AND Day="21 November"
I am new to SQL with no access to a DBMS, any help would be appreciated.