Tuesday, 10 September 2013

An expression of non-boolean type specified in a context where a condition is expected, near 'Begin'

An expression of non-boolean type specified in a context where a condition
is expected, near 'Begin'

Present i am working on hotel project i need to check the availability of
rooms with the help of these stored procedure, Here the logic is first
need to check the room availability if it is not available then i need to
check if checkout date entered by the customer is equal to the checkout
date of any customer
ALTER PROCEDURE [dbo].[customerdetails] (@CheckIn DATE,
@CheckOut DATE,
@RoomType VARCHAR(50),
@NoOfPersons INT,
@Adults INT,
@Children INT,
@FirstName VARCHAR(50),
@Address VARCHAR(50),
@City VARCHAR(50),
@PhoneNumber VARCHAR(50),
@Email VARCHAR(50))
AS
BEGIN
BEGIN TRY
IF ( (SELECT Available
FROM rooms
WHERE roomtype = @RoomType) > 0 )
BEGIN
INSERT INTO Customerdetail
VALUES (@CheckIn,
@CheckOut,
@RoomType,
@NoOfPersons,
@Adults,
@Children,
@FirstName,
@Address,
@City,
@PhoneNumber,
@Email)
END
ELSE IF(SELECT *
FROM Customerdetail
WHERE RoomType = @RoomType
AND CheckOut = @CheckOut)
BEGIN
INSERT INTO Customerdetail
VALUES (@CheckIn,
@CheckOut,
@RoomType,
@NoOfPersons,
@Adults,
@Children,
@FirstName,
@Address,
@City,
@PhoneNumber,
@Email)
END
END TRY
BEGIN CATCH
DECLARE @ErrMessage NVARCHAR(max)
SET @ErrMessage=ERROR_MESSAGE()
RAISERROR (@ErrMessage,16,1)
END CATCH
END

No comments:

Post a Comment