CREATE PROCEDURE DBO.UpdateHotelSetupChainSettings @AHotelCustomerNumber INT, @AHotelSetupNumber INT, @AValue VARCHAR(50) AS
/*
  Created by Kent Johansen
  Used to update hotelsetup settings when running domino
  Currently only used from dbupdate\post\once

*/

SET NOCOUNT ON

DECLARE @HotelSetupValueNumber INT
DECLARE @Identity INT

SELECT @HotelSetupValueNumber = FK_ValueNumber FROM HotelSetupValueXTab WITH (NOLOCK) WHERE CustomerNumber = @AHotelCustomerNumber AND HotelSetupNumber = @AHotelSetupNumber

IF ISNULL(@HotelSetupValueNumber, 0) = 0
BEGIN
  INSERT INTO HotelSetupValue (KeyValue) VALUES (@AValue)
  SET @Identity = @@Identity
  INSERT INTO HotelSetupValueXtab VALUES (@AHotelSetupNumber, @AHotelCustomerNumber, @Identity)
END
ELSE
  UPDATE HotelSetupValue SET KeyValue = @AValue WHERE PK_ValueNumber = @HotelSetupValueNumber
GO
