Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Statement Logic
Message
From
15/02/2008 11:00:01
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
SQL Statement Logic
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01292989
Message ID:
01292989
Views:
54
The Validate_ variables are just populated from the current record, then the SQL compares that against the table to find out if there are any others that match the criteria. This is to find any conflicts.

The problem with the SQL below is that if the Validate StartHour and EndHour both land outside the block of time being compared against, it does not return any records. It should be able to determine if any hours between the StartHour and the EndHour fall within the criteria. I'm about ready to just break this up into about 10 different SQL statements and have each one pull from the one created before it, but thought I would see if anyone here saw something obvious.
* Rule Validations

Validate_RecNo = RECNO('AppointmentTypeSets')

Validate_disp_off = AppointmentTypeSets.S_Offr
Validate_doc_code1 = AppointmentTypeSets.S_Coder
Validate_FromDate = AppointmentTypeSets.FromDate
Validate_ToDate = AppointmentTypeSets.ToDate
Validate_Day = AppointmentTypeSets.Day
Validate_sx_starttime = AppointmentTypeSets.StartHour
Validate_sx_startmin = AppointmentTypeSets.StartMin
Validate_sx_endtime = AppointmentTypeSets.EndHour
Validate_sx_endmin = AppointmentTypeSets.EndMin

SELECT * FROM AppointmentTypeSets INTO CURSOR crsApptRuleValidate WHERE ;
	(BETWEEN(Validate_FromDate, AppointmentTypeSets.FromDate, AppointmentTypeSets.ToDate) OR ;
	BETWEEN(Validate_ToDate, AppointmentTypeSets.FromDate, AppointmentTypeSets.ToDate)) AND ;
	(((Validate_sx_starttime > AppointmentTypeSets.StartHour AND Validate_sx_starttime < AppointmentTypeSets.EndHour) OR ;
	((Validate_sx_starttime = AppointmentTypeSets.StartHour AND Validate_sx_startmin >= AppointmentTypeSets.StartMin) OR ;
	(Validate_sx_starttime = AppointmentTypeSets.EndHour AND Validate_sx_startmin <= AppointmentTypeSets.EndMin))) OR ;
	((Validate_sx_endtime > AppointmentTypeSets.StartHour AND Validate_sx_endtime < AppointmentTypeSets.EndHour) OR ;
	((Validate_sx_endtime = AppointmentTypeSets.StartHour AND Validate_sx_endmin >= AppointmentTypeSets.StartMin) OR ;
	(Validate_sx_endtime = AppointmentTypeSets.EndHour AND Validate_sx_endmin <= AppointmentTypeSets.EndMin)))) AND ;
	AppointmentTypeSets.S_Coder = Validate_doc_code1 AND ;
	(UPPER(TRIM(AppointmentTypeSets.Day)) = UPPER(TRIM(Validate_Day))) AND ;
	AppointmentTypeSets.S_Offr = Validate_disp_off AND ;
	RECNO() <> Validate_RecNo

Validate_RecCount = RECCOUNT('crsApptRuleValidate')
Next
Reply
Map
View

Click here to load this message in the networking platform