• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 81
  • Last Modified:

Appointment Rebooking

I need some assistance with some SQL

I have a table that contains appointments

AppName       AppDate         AppTime

After an appointment has been booked, a ' Rebook' button is available for people to rebook that appointment if the time and date changes..

This all works but what I want to do now is this.

When people try to rebook I DON"T want them to be able to choose a date that is AFTER the next appointment.

e.g

Appointment 1    01/05/2015

Appointment 2     15/05/2015

If people choose to rebook appointment 1 then I want it to stop people choosing a date beyond Appointment 2.  So the only available dates to rebook would be between 01/05/2015  and 15/05/2015.

Thanks
0
Ed
Asked:
Ed
  • 2
  • 2
1 Solution
 
Easwaran ParamasivamCommented:
Simple. Add validation by calling an SP while re-booking. Pass the selected date as input parameter to the SP


create proc Validate (@Input datetime)
as
begin
 
declare @retvalue int =  0


--Assuming tTable contains the Appointment2  data value. Kindly change in your case accordingly.
if exists (select   1
from tTable where   Appointment2 < @Input )
set @retvalue =  0
else
set @retvalue =  1

--In UI read the @retvalue. If it is 1 then it fails the validation. In this case don't allow to rebook

 

end
0
 
EdAuthor Commented:
thanks, could you give a bit of SQL to assist with this?
0
 
Easwaran ParamasivamCommented:
0
 
EdAuthor Commented:
Perfect , thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now