Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SELECT or view?
Message
From
12/04/1998 00:39:43
 
 
To
11/04/1998 23:44:00
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00091365
Message ID:
00091371
Views:
20
In my opinion views should normally be used instead of a SELECT in a form where the selection criteria is subject to change.

For basic selection changes in your views you can define a variable to prompt for or pre-set.
SQL WHERE Example:
WHERE EmpID = ?lcEmpId

The '?' is a special designator. If you preset the value of lcEmpId the view will be populated based on that value. Otherwise the user will be prompted for the value.

=REQUERY('') will repopulate the view.

To make a view into a Swiss-Army knife, you can do macro expansion in the where clause.
Example:
lcSqlWhere = [EmpId = '] + lcEmpId + [' AND StatusCd ='] + lcStatusCd + [']

Then in the SQL Where
WHERE &lcSqlWhere

Using macro expansion may cause problems when not careful with remote views.

The basic code to create a view is

CREATE SQL VIEW (pcView) AS;
SELECT ;
Hist.*;
FROM ;
Hist ;
WHERE ;
HistId = ?lcHistId
AND ! DELETED()

You will also need to set various view field and table properties.

The best way of seeing the different requirements for view code is to use the View designer and create some views. Then use GenDbc to create the DBC source code listing. This will detail the creation of the view and the setting of all the properties.

-myron kirby-
myronk@flash.net
-----------------------------------------------------------------------------------

>Here's the situation:
>
>The form have a 3 pages page frame:
>Page 1: edit fields and navigations buttons
>Page 2: list of all available records in a grid
>Page 3: filtering options
>
>They are many different combination of filtering conditions that the user can make.
>
>On what should I base my form: a view or a SELECT-SQL?
>
>A SELECT-SQL seem easier to use, but I can't edit it directly. A view would be more appropriate to do the editing, but the filtering options are bothering me. How can you build a view with changing criteria? Build a view programmaticaly? If so, would I need to initialize every fields "RecordSource" property everytime the filter is changed?
>
>I need your advise on this.
>
>TIA
----------------------------------
-myron kirby (mkirby2000@gmail.com)-
Previous
Reply
Map
View

Click here to load this message in the networking platform