Курсовая работа: Автоматизированная система бронирования авиабилетов
)
RETURNS int
BEGIN
DECLARE @count int;
IF EXISTS (SELECT OrderID FROM Orders WHERE FlightID=@flightID
AND Number2cl>0)
SELECT @count=Aircrafts.Count2
-(SELECT SUM(Number2cl) FROM Orders WHERE FlightID=@flightID)
FROM Flights,Aircrafts WHERE Flights.FlightID=@flightID
AND Flights.AircraftID=Aircrafts.AircraftID
ELSE
SELECT @count=Aircrafts.Count2
FROM Flights,Aircrafts WHERE Flights.FlightID=@flightID
AND Flights.AircraftID=Aircrafts.AircraftID
RETURN @count
END
Для получения информации по рейсам было создано представление FlightView:
CREATE VIEW [dbo].[FlightView] AS
SELECT
FlightID,
DateDeparture,
DateArrival,
dbo.timeFlight(DateArrival,DateDeparture) AS TimeFlight,
CityDepartureID,
CityArrivalID,
DepartureCities.CityName AS CityDeparture,
ArrivalCities.CityName AS CityArrival,
CompanyName,
AircraftModel,