Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Views
Message
De
05/11/1998 17:20:44
 
 
À
05/11/1998 02:58:20
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Views
Divers
Thread ID:
00154664
Message ID:
00155037
Vues:
27
>>I need help setting "views" in a form.
>>I have a form with a page frame and two pages. One with detail records and another containing a grid.
>>I need to be able to view the data, say Names.dbf, either completely or "filtered" to only those key values contained in a selected table whose name will vary, but call it the "Query" table. There is a whole set of "query" tables predefined that the use can choose from a popup. The popup is outside the pageframe, so can be changed either while details or the grid is displayed.
>>
>>So Names.dbf might contain fields pkey i, name c(40), town c(30)... etc, but all the query tables only contain a single field pkey i. Get the idea?
>>
>>So how do efficiently set up an editable view which is essentially either..
>>
>>SELECT * from Names where pkey in (select pkey from "query") && where "query" can change
>>or
>>all records in Names if user chooses no filter.
>>
>>I can handle the SQL but how do I parameterise the view expression?
>>How do I change the source of the grid to match?
>>
>>You see if I did this in FPW 2.6 it's simple, it's fast, I wouldn't even need to run a query, just set a relationship from Query into Names, and that would work in the browse as well. But I'm not sure on the best approach in VFP.
>>
>>I'm sorry this is a complicated question, but it's a sort of design structure that comes up often in my sort of apps. So would really appreciate a jump start.
>David,
>Why not do it like FP 2.6 way - still with view :) Views are also indexable so create an index on PKid field (or PKid+defaultorderfield), set grid's linkmaster, childorder, relationalexpression fields.
* Old relation style
>use child in 0 order tag myorder
>select master  && Master is your query
>set relation to pkid into child
>* Correspond to
>ChildOrder = "myOrder"
>LinkMaster = "master"
>RelationalExpression = "pkid"
>recordsource = "child"
Say in fact you want to order names on dBirthDate. You would index view on pkid+dtos(dBirthDate) tag myOrder because just in old relation style (for me in fact not old, still lives :) you wouldn't change order of child to something that doesn't start with pkid (which is RelationalExpresion). This works fast and I use this way. OTOH w/o relation, all view style is possible too :) View's SQL expression would be a parameterized (pseudo) view.
SELECT * from Names ;
>  where pkey in ;
>       (select pkey from (thisform.tcQuery))
>* Instead of hardcoding "query" now
>* custom form property "tcQuery" holds ref to needed table
>* At first you could set tcQuery to "crsAllNames"
>* In Form.load, DE.beforeopentables whereever applicable
>* select pkid from names into cursor crsAllNames
>* Anytime "query" table changes, you would simply
>* put new "query" tablename into tcQuery and requery(cYourView)
>* Grid.recordsource would always be the view itself
Cetin

Thanks for that input Cetin.
I do like the old way, but have such a nightmare with grid stability using link master (doesn't always refresh properly) to which people here say 'use views'.
My real problem with the view here is that I need to set up a view which is essentially...
select * from a where a.pkey in (select pkey from b)
and table b can be changed by the user.
Also the view may be simply
select * from a
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform