Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Controls, Events, Commands, and More : Page 3

Dive right in to Visual FoxPro 9.0's new properties, events, and methods; new or improved commands; and FoxPro Foundation Classes (FFCs).


advertisement
Log Execution Plan's Output from SYS(3054) Using SYS(3092)
The SYS(3054) function is very helpful for optimizing SQL queries, as it produces an execution plan of which indexes, if any, are in use, and enables optimization of queries by creating new indexes or fine-tuning the way the queries are written. The new SYS(3092) function provides the ability to write the output of SYS(3054) directly to a file on disk.

*-- Turn on execution plan. Sys(3054, 12) *-- Set up output file. Sys(3092, "c:\ExecutionPlan.txt", .T.) *-- Run Query. Select * ; from Home(1)+"\samples\northwind\Customers" ; into cursor curCustomers *-- Turn off output and close file. Sys(3092, "") *-- Let's see the log. Modify File "c:\ExecutionPlan.txt"

Extended SQL Capabilities
There are many improvements to the SQL subset in Visual FoxPro 9. With each new release, the VFP team moves Visual FoxPro's SQL closer to T-SQL (SQL Server's SQL implementation).

Some of the most notable improvements are:

  • The limit of nine join clauses and sub-queries was removed from the SQL Select statement, as were the nine Union clauses limit, the 30 tables limit, and the referenced aliases limit.
  • The level of nesting for sub-queries in a SQL Select statement, formerly limited to only one level, is now unlimited.
  • The list of fields and the FROM clause can now have a sub-query. This works for the ON clause on joins as well.
  • The Like clause is now optimized.
Make sure to read the Data Features Enhancements section under the "What's New" topic in the Visual FoxPro Help file for more specific information about all the improvements on these subjects.

Set Coverage Command Available at Run Time
The Set Coverage command is now available at run time. Anywhere inside an application, you can call the Set Coverage command like this:

SET COVERAGE TO C:\MyApp.log

The Set Coverage command creates a log file for the code being executed. The Coverage Profiler tool (available on the Visual FoxPro IDE from the Tools menu) can then be used to analyze this log file. The Coverage Profiler tool shows the code's coverage, indicating which lines are being executed, and which ones never get executed; it also shows statistics, such as how many times a line is executed, and how long that takes, helping you find code bottlenecks.

The SQLExec function makes it possible to get cursor and count records affected by the SQL Pass-Through command
This new ability of enabling coverage during runtime is also useful for debugging errors that occur during runtime, but that never happen in interactive mode (through the Visual FoxPro IDE).

Populate an Array with Aliases Used by a Specified Table
The AUsed function improved to allow passing a third parameter, one that indicates that the array created by this function should only look for aliases of a specific table. The following code snippet shows a simple example:



Select * ; from Home(1)+"\samples\northwind\Customers" ; into cursor curCustomers Select * ; from Home(1)+"\samples\northwind\employees" ; into cursor curEmployees ? AUSED(gaInuse, Set("Datasession"), "Employees") DISPLAY MEMORY LIKE gaInuse

In the preceding code, an array shows the aliases and work area numbers for the Employees table available at the current data session.

SQLIdleDisconnect() Temporarily Disconnects SQL Pass-Through Connections
The new SQLIdleDisconnect function is a great new addition to the SQL Pass-Through set of functions. This function temporarily disconnects a connection handle passed to it (or it disconnects all connections, if you pass a 0).

That's a great feature for disconnected scenarios, where an application doesn't have to hold a connection to the database when the user is only reading retrieved data, rather than sending data back and forth regularly. Plus, when the connection must be enabled again to process something, it happens automatically, using the original connection string.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date