>In a SQL select statement. (original code VFP 5) I came across the code below as part of the WHERE clause
>
>(Empty(?ThisForm.Customer) or ?ThisForm.Customer= Ordhead.customerid)
>
>
>As stated previously, empty is not rushmore optimizable, therefore how do I change this to return the same info. I am rewriting the queries in VFP 9 and wish to get the same results.
>
>Mike
Depedning on the type of thisform.Customer (I assume it's Integer) you can also do
?thisform.Customer = 0 OR OrderHead.CustomerID = ?thisform.Customer (also you don't need ? here, the result would be the same without it).
The idea of this query is to allow "All" records in case the parameter was not supplied. So, if the parameter is Integer, you check for 0. If it's character, you check
thisform.Customer ==""
if it's a date, you check with thisform.Date = {}
For empty datetime you may check with thisform.DateTime = {::} (if I recall correctly).
I think it covers most of types.
If it's not broken, fix it until it is.
My Blog