I have a function and a trigger as below:
CREATE FUNCTION update() RETURNS TRIGGER AS $logupdate$
DECLARE
judge boolean;
BEGIN
judge := EXECUTE ('SELECT starttime,endtime,NEW.starttime,NEW.endtime FROM reserves WHERE bid = NEW.bid AND startdate = NEW.startdate AND (starttime,endtime) overlaps(NEW.starttime,NEW.endtime) IS NULL');
IF judge = f THEN RETURN false;
END IF;
RETURN NEW;
END;
$logupdate$ LANGUAGE plpgsql;
CREATE TRIGGER logupdate
before UPDATE ON reserves
FOR EACH ROW
EXECUTE PROCEDURE update();
The trigger should detect if the new input has overlapping with previous time, for example if there is an old time in my table [11:00 - 13:00], and a new input is [12:00 - 14:00] then the trigger should fire at it and stop insertion. However, it doesn't work in my computer, what's wrong here?