Q:

"Error Code: 2014. Commands out of sync; you can't run this command now" while creating a trigger

I am trying to write a trigger that in case of inserting will do following:
1)count number of seats in the plane
2)count number of passengers that are already on this flight
3)compare these values and insert new row into the table OR raise an error saying that there are no more free seats in the plane.
Here is my code:
DELIMITER //
USE AIRPORT;
CREATE TRIGGER CHECK_FOR_PLACES
BEFORE INSERT ON TICKET
FOR EACH ROW
BEGIN
DECLARE NUM_OF_PLACES INT;
DECLARE NUM_OF_PASSENGERS INT;

SET NUM_OF_PLACES := (SELECT CAPACITY
FROM AIRPLANE
INNER JOIN FLIGHT ON FLIGHT.ID_AIRPLANE = AIRPLANE.ID_AIRPLANE
WHERE FLIGHT.ID_FLIGHT = NEW.ID_FLIGHT);

SET NUM_OF_PASSENGERS := (SELECT COUNT(*)
FROM TICKET
WHERE TICKET.ID_FLIGHT = NEW.ID_FLIGHT);

IF NUM_OF_PASSENGERS >= NUM_OF_PLACES THEN
    SIGNAL SQLSTATE '-20000' SET MESSAGE_TEXT = 'NO MORE PLACES ON THIS FLIGHT';
END IF;
END//
DELIMITER ; 

After trying to compile the script I get the following error:
Error Code: 2014. Commands out of sync; you can't run this command now

I have no idea what might be the reason of this error. I'd appreciate any help. Thanks in advance

A:

use airport is a separate statement, should be terminated by // since you changed the delimiter:
DELIMITER //
USE AIRPORT//
...

