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" ... I was searching the syntax for the function... A bit confuse why some of function need the BEGIN and some are not..
Can anyone please give me some hint..thanks so much..!