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;
It said that the syntax error near "IF" ...
A bit confused why some functions need the BEGIN
and some do not.
Can anyone please give me a hint?