Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Views
Message
De
01/12/1999 12:06:24
 
 
À
01/12/1999 11:30:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Re: Views
Divers
Thread ID:
00297345
Message ID:
00297373
Vues:
21
>so I'm trying to get a grasp on views and how they relate to the tables in a dbf. I also need some info on parameterized views. Can anyone please give me a basic(very basic) explanation of what a view and a parameterized view is.

Well, if you haven't done so yet, start by reading Chapters 5 and 6 of the VFP Users Guide (in the OnLine Help that came with VFP) and Chapter 8 of the Programmer's Reference (also part of the OnLine Help.)

A parameterized view is nothing more than a view (a specialized type of query that can be based on one or more tables, treated as if the result were in and of itself a flat table) that has embedded parameters (variables) that can be set to set the specific values of a an expression at runtime. The parameterized view has predefined variable references stored in it; if it finds matching variables in scope when a USE or REQUERY() occurs, it uses the presently-defined values, otherwise, it'll pop a little dialog box to prompt you for the value of the variable at runtime.

A simple example - I have a table called Members that includes the name and address information for people that looks something like:

Name C(50),StreetAddr C(50), City C(25), State C(2), Zipcode C(10)

I have a section of the application where I need to work with just people from CT; I could create a view in my DBC that looked like

CREATE SQL VIEW CTResidents AS SELECT * FROM Members WHERE State = 'CT'

If I now needed the Georgia residents, I could have a second view

CREATE SQL VIEW GAResidents AS SELECT * FROM Members WHERE State = 'GA'

Using this approach, you'd need 50 separate views. Instead, why not write one view that takes a parameter value for the value to check in my WHERE clause?

CREATE SQL VIEW StateRes1 AS SELECT * FROM Members WHERE State = ?cResState

The ?cResState tells VFP that, if a variable cResState is in scope, it should be used as the argument in the WHERE clause. If the variable cResState does not exist, VFP will pop up a dialog box asking you to fill in the value for cResState.

Parameters can be used anywhere on the right side of a compare operator, or as an argument in an expression - there are complications when you try to set up parameterized views where you need to macro-expand the parameter variable at runtime, although its fairly trivial to use them in EVAL().

There's considerably more to the topic, but this should give you a simple idea of what a parameterized view does.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform