CREATE FUNCTION check_available_flightID(date)
RETURNS integer AS
$$
BEGIN
SELECT FlightID FROM Flight WHERE FlightDate::date = $1;
IF NEW.FlightID IS NULL THEN
RAISE EXCEPTION 'No filight in the date you enter'
END IF;
RETURN query SELECT FlightID FROM Flight WHERE FlightDate::date = $1;
$$
LANGUAGE SQL;
它说“IF”附近的语法错误......有点困惑为什么有些功能需要BEGIN
而有些不需要。
谁能给我一个提示?