Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL, Views, and Macro Substitution
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro Beta
Divers
Thread ID:
00921296
Message ID:
00922114
Vues:
33
Thanks for summarizing this Paul!

>Aleksey,
>
>I truly appreciate your help! I spent the better part of a day trying to figure this one out and didn't get all of the puzzle pieces in quite the right place. I must tell you that you guys are doing a fabulous job! I appreciate the fine product you put out as do my clients.
>
>For anyone following this thread, I just want to recap what I have learned from everybody's input.
>
>VFP 9.0 (Beta at this time) - Views that use Macro-Substitution
>If your view definition is something like:
> CREATE SQL VIEW myview AS SELECT mytable.* from mydbc!mytable WHERE &cFilter
>
>The value of the variable "cFilter" is macro-substituted as the literal "where clause" for the select statement at run-time.
>
>You must change your definition to include the question mark:
> CREATE SQL VIEW myview AS SELECT mytable.* from mydbc!mytable WHERE &?cFilter
>
>To create/use Views that use macro-substitution, you must follow these rules:
>
>1. You MUST put a "?" question mark on the front of your parameter (just like you did prior to VFP 8.0).
>
>2. You MUST have defined a variable with the same name as your parameter PRIOR to defining the view (in previous version, it was the opposite).
>
>3. Additionally, this defined variable: must be of type STRING, it must NOT be empty, it must be in SCOPE, and the VALUE of the variable must be able to be compiled without errors (like ".T.").
>
>4. Since using macro-substitution in Views was not "intended" functionality (and is not documented), you still cannot use the much improved View/Query Designer when working with macro-substituted parameters (huge bummer), these views must be created via code (or a cool utility such as ViewEdit or EView).
>
>5. At RUN-TIME a form that contains a View (with a macro-substituted parameter) in it's Data Environment, the "variable" name that is used in the View Definition must exist as a compilable non-empty string BEFORE the view is opened. This is true even if the View is opened with NODATA. (This can be done using the Data Environments BeforeOpenTables() method, public variable, etc.)
>
>6. The setting of ENGINEBEHAVIOR has no effect on these rules.
>
>
>If you attempt to use a macro-substituted view without following these rules:
>
>At design-time or using some utilities, you could get a "Syntax Error" because the WHERE clause won't compile.
>
>At run-time you could get the error: Error loading file - record number xxx. xxMyFormNamexx (or one of its members). Loading the form or data environment : variable 'xxxx' is not found.
>
>Thanks,
>Paul James
Mike C.
-------
I keep trying to find a life of my own, apart from you.
DC Talk/Charlie Peacock, In the Light.
www.risensystems.com/ra/itlbegin.rm
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform