I'm trying to use PL/SQL to create a trigger that will stop double booking entries. Based on a duration field and a start time.
[code=oracle]
Create or Replace Trigger LeaseChk
Before insert on Lease
Begin
IF :NEW.StartDate and :NEW.Duration >= :OLD.StartDate and NEW.Duration (Some sort of Between Date Function i think)
Where :NEW.PropertyID and :NEW.RoomID = :OLD.PropertyID and :OLD.RoomID
Then
RAISE_APPLICATI ON_ERROR (-20500, 'There is already a Lease created for this Property and Room for this time');
End IF;
END;
/
[/code]
Any help would greatly be appreciated!
[code=oracle]
Create or Replace Trigger LeaseChk
Before insert on Lease
Begin
IF :NEW.StartDate and :NEW.Duration >= :OLD.StartDate and NEW.Duration (Some sort of Between Date Function i think)
Where :NEW.PropertyID and :NEW.RoomID = :OLD.PropertyID and :OLD.RoomID
Then
RAISE_APPLICATI ON_ERROR (-20500, 'There is already a Lease created for this Property and Room for this time');
End IF;
END;
/
[/code]
Any help would greatly be appreciated!
Comment