SET ENGINEBEHAVIOR Command
| Visual FoxPro 9.0 SP2 |
| SET ENGINEBEHAVIOR Command |
| See Also |
|
Enables SQL data engine compatibility with Visual FoxPro 7.0, 8.0, and 9.0.
SET ENGINEBEHAVIOR 70 | 80 | 90 |
Parameters
- 70
-
Specifies that Visual FoxPro treat SQL commands with behavior as in versions before Visual FoxPro 8.0.
- 80
-
Specifies that Visual FoxPro treat SQL commands with behavior as in Visual FoxPro 8.0.
The following table describes behavior for the SQL SELECT statement.
SQL SELECT clause Behavior DISTINCT
You cannot use the DISTINCT clause with Memo or General fields. Instead, wrap a Memo field inside a function such as PADR( ) or ALLTRIM( ).
For more information, see PADL( ) | PADR( ) | PADC( ) Functions and ALLTRIM( ) Function.
UNION
The UNION clause does not support Memo fields unless the ALL clause is included in the SQL SELECT statement.
GROUP BY
The GROUP BY clause must list every field in the SELECT list except for fields contained in an aggregate function, such as the COUNT( ) function. In addition, the GROUP BY clause must also list every field in a HAVING clause except for fields contained in an aggregate function.
For example, the following code raises an error because the field
companyis not listed in the GROUP BY clause.
Copy CodeSELECT company, country FROM Customer GROUP BY country
You can include an aggregate function in the SELECT list without having it in the GROUP BY clause.
For example, the following code uses the COUNT( ) function on the field
companywithout having the fieldcompanyin the GROUP BY clause.SELECT COUNT(company), country FROM Customer GROUP BY countryHAVING
A SQL SELECT statement can contain the HAVING clause without the GROUP BY clause as long as the SQL SELECT statement does not contain any aggregate functions.
For example, the following code filters query results by specifying the country field must equal "Sweden".
Copy CodeSELECT customerid FROM customers HAVING country="Sweden"
LIKE
SQL SELECT statements do not automatically remove trailing spaces from values compared with the LIKE operation. In versions before Visual FoxPro 8.0, both values in the LIKE operation were trimmed from the right before evaluation.
For example, the following code assumes that you have a table named
table1, and the table has three rows that contain values of "1.", "12 ", and "123", respectively.
Copy CodeSELECT * FROM table1 WHERE column1 LIKE "1__"
Visual FoxPro 7.0 and earlier returns one row with the value of "123". Visual FoxPro 8.0 returns three rows with the values, "1 ", "12 ", and "123".
If the beginning of the filter condition matches the pattern of the expression in the LIKE operation, and the rest of the filter condition contains trailing spaces, the LIKE operation ignores the trailing spaces and returns True (.T.). Trailing spaces in the pattern are not ignored.
- 90
-
Specifies that Visual FoxPro treat SQL commands with standard Visual FoxPro 9.0 behavior. This is the default setting.
The following table describes behavior for the SQL SELECT statement.
SQL SELECT clause Behavior TOP nExpr
When you enable this setting, including the TOP nExpr [PERCENT] clause in the SQL SELECT command returns no more than nExpr [PERCENT] records. In addition, the SQL engine uses available memory more efficiently and it speeds evaluation for the TOP clause without the PERCENT keyword when you work with large result sets, low memory conditions, or both.
GROUP BY
When you use aggregate functions, such as MAX( ), in the SQL SELECT command without a GROUP BY clause, and the system does not find any matching records, Visual FoxPro returns a result set with a single record and it sets _TALLY to 1. In versions before Visual FoxPro 9.0, the system does not return any records and it sets _TALLY to 0.
ORDER BY
A SELECT … DISTINCT … ORDER BY command will generate an error if the specified ORDER BY field is not in the SELECT field list.
Copy CodeCREATE CURSOR foo (f1 int, f2 int) SELECT DISTINCT f1 FROM foo ORDER BY f2 INTO CURSOR res
HAVING
A SELECT … DISTINCT … HAVING command will generate an error if the specified HAVING field is not in the SELECT field list.
Copy CodeCREATE CURSOR foo (f1 int, f2 int) SELECT DISTINCT f1 from foo HAVING f2>1 INTO CURSOR res
Remarks
See Also
© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic
Microsoft Visual FoxPro 9 SP2 Help file, VFPX Edition v1.08