CLEAR PROMPT

Modify View, Rename View

These commands let you perform maintenance on views. MODIFY VIEW opens the View Designer to edit an existing view (or create a new view). RENAME VIEW lets you change the name of an existing view.

Usage

MODIFY VIEW [ ? | ViewName [ REMOTE ] ] RENAME VIEW OldName TO NewName
If you don't specify a view to modify, you're prompted with a list of all the views in the current database. The REMOTE keyword seems to be not only superfluous, but totally ignored. We can't find any situation where you'd need it.

As with other database maintenance, in VFP 3 you need exclusive use of the database to use these commands.

Be careful what views you open with MODIFY VIEW, or more precisely, what views you save once you've opened the View Designer. It can't handle any but the simplest views. In particular, the View Designer has problems with table relationships that involve what we like to call "unrelated siblings;" that is, tables that are both children of the same parent but do not have an inherent relationship. (For example, the TasTrade Orders table can be seen as parent to both the Customer and Shipper tables. But customer and shipper have no relationship.) In addition, if you've written a view by hand, there's a good chance the View Designer can't parse it correctly. When you open a view beyond its abilities, it makes it up as it goes. If you save the nonsense the View Designer comes up with, your view will be damaged. One basic rule—if you open a view with the View Designer and it looks funny, press ESC and get out without saving.


If you rename a view and other views are based on that view, the dependent views won't work anymore. You can't even open them up in the View Designer to fix the problem without losing the definition. You can fix things up by using DBSetProp() to gather and store all the relevant properties, and then redefine the view. The big problem, of course, is knowing that you have views dependent on a renamed view.


Modifying a view changes the current work area. While this is easily worked around, it can bite you if you're not expecting it.


In all versions, the database containing the view must be current.

In VFP 7, if the database has database events turned on, MODIFY VIEW fires the BeforeModifyView and AfterModifyView events (and the BeforeOpenTable and AfterOpenTable events for the underlying tables) and RENAME VIEW fires BeforeRenameView and AfterRenameView.

Example

MODIFY VIEW MyRemoteView RENAME VIEW ShortName TO MuchLongerAndMoreExplicitName

See Also

AfterModifyView, AfterRenameView, BeforeModifyView, BeforeRenameView, Create SQL View, DBSetProp(), Open Database, Set Database


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net