/*

  Author: Brian Andersen
  Created: 080213
  Purpose: Returns the Status number as a String

  ReservationTL.Pas:
  TReservationStatus = (
    rsConfirmed, // 0     // Reservationsstatuses. NOTE! Changing the order of these will have devastating effects!
    rsProvisional, // 1
    rsGuaranteed, // 2
    rsWaitinglist, // 3
    rsTentative, // 4
    rsInhouse, // 5
    rsOutOfHouse, // 6
    rsCancelled, // 7
    rsNoShow); // 8


*/

CREATE FUNCTION dbo.GetReservationStatus(@AStatus INT)
RETURNS VarChar(30)
AS
BEGIN
  DECLARE @Text VarChar(30)

  SET @Text = CASE @AStatus
    WHEN 0 THEN 'Confirmed'
    WHEN 1 THEN 'Provisional'
    WHEN 2 THEN 'Guaranteed'
    WHEN 3 THEN 'Waitinglist'
    WHEN 4 THEN 'Tentative'
    WHEN 5 THEN 'In house'
    WHEN 6 THEN 'Out of house'
    WHEN 7 THEN 'Cancelled'
    WHEN 8 THEN 'No show'
  ELSE  
    'Status not defined: ' + Convert(VARCHAR(10), @AStatus)
  END
  RETURN @Text
END