When you create a view in the View Designer, Visual FoxPro builds a SQL SELECTВ statement to retrieve the information from the fields in the tables. You can see and edit the SQL SELECT statement that Visual FoxPro builds and the properties set for the view in the SQL window. Any changes that you make in the SQL window are preserved during the loading or generation of the view.
To display the view definition
Open the view in the View Designer.
On the Query menu, click View SQL.
The SQL window for the view opens and displays the SQL SELECT statement generated automatically for the view and properties for the view. For more information, see SELECT - SQL Command and DBSETPROP( ) Function.
For example, suppose you create a view in the View Designer using the sample Northwind database and select all records in the Customers table where the Country field contains the value "Canada". The following SQL SELECT statement appears in the SQL window when you open it:
SELECT *; FROM Northwind!Customers ; WHERE Customers.Country = "Canada"
You can also include the SQL SELECT statement in code by copying the SQL SELECT statement from the SQL window into a program (.prg) file. You can also run the SQL SELECT statement immediately by copying the statement and running the statement in the Command window.
|If you want to process the statement only after you type the last line, type each clause on a separate line in the window and end each line except the last one with a semicolon (;).|
To edit the view definition
In the SQL window, edit the SQL SELECT statement or view properties.
To update the View Designer, close the SQL window or click the View Designer to make it the active window.
The View Designer is updated with the changes you made to the view definition.
|If the View Designer cannot reload your changes after you make changes in the View SQL window, a dialog box appears with the following prompt:|
"View/Query designer is unable to reload your changes. Would you like to rebuild content from the designer?"
Clicking Yes discards your changes in the SQL window and returns you to the View Designer. Clicking No returns you to the SQL window.
|To save a statement that cannot be parsed such as a call to a stored procedure, click No, and then Save on the standard toolbar. Visual FoxPro saves the query. You can save the query by clicking Save on the standard toolbar after typing the command in the SQL window. You do not need to click the View Designer window, which causes the View Designer to try to load and parse the query.|