Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Macro substitution in sql views no longer possible
Message
De
11/01/2005 05:30:24
 
 
À
10/01/2005 23:03:16
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
00975746
Message ID:
00975965
Vues:
43
>Hi sergey,
>
>>It still works in VFP9 but you have to code it differently:
>
>>- The variable lcMacrotest has to be defined before view is created
>>- The variable lcMacrotest should be precceded by '?' in the view
>>
create sql view lvMacrotest as sele * from macrotest where &?lcMacrotest
>
>I don't understand why this is this way.
>- In VFP7 both strategies work (&cWhere and &?cWhere)
>- In VFP8 only &cWhere works
>- In VFP9 only &?cWhere weems to work
>
>I'd say this is a bug in an attempt to fix something reported in Yet another BUG: Macros in view definition not supported Thread #753139 Message #753139
>
>Walter,

Hi Walter

Moreover, these three writings
&cVarname and &?cVarname and ?&cVarname
are formally different, because a inner resolution return different results:
where = 'ON'
cWhere='where 4>5'
cWhereReference = 'cWhere'
* 1
&cWhere           => where 4>5
&cWhereReference  => cWhere
* 2
&?cWhere           => &EVAL(cWhere)          => &where 4>5   => ON 4>5
                                         or  => &(where 4>5) =>  ERROR  
&?cWhereReference  => &EVAL(cWhereReference) => &cWhere      => where 4>5
* 3
?&cWhere           => ?where 4>5   => expectet ERROR
?&cWhereReference  => ?cWhere      => 'where 4>5' => error
                                or =>  where 4>5
Then, the only formal solution for current VFP is:
& &? ?& are equals.
But this is not true fully, and different context return different errors.


I think that this formal error creates much confusion, also in the VFPT.

I run this, and this show the incoherence, BUT HERE &cWhere whork !:
CLEAR

cWhere = 'WHERE 5>C'
cMacro = '1'

SYS(3054,0)
CREATE DATABASE testMacroParameters
CREATE CURSOR byby (c i)
INSERT INTO byby VALUES (3)
INSERT INTO byby VALUES (6)

CREATE SQL VIEW view1 as SELECT c,1 FROM byby &cWhere  && no errors
SELECT c,1 INTO CURSOR direct1  FROM byby  &cWhere     && no errors
USE view1 IN 0  

SELECT c,2 INTO CURSOR direct2  FROM byby ?&cWhere        && no error VFP discard ?
CREATE SQL VIEW view2 as SELECT c,2 FROM byby ?&cWhere    && execute fire a  error here

SELECT c,3 INTO CURSOR direct3 FROM byby &?cWhere         && COMPILE FIRE A ERROR HERE
CREATE SQL VIEW view3 as SELECT c,3 FROM byby &?cWhere    && VFP reduce &? to &

USE view3 IN 0   && no errors

cWhere1 = 'WHERE '
cWhere2 = '5>C'

CREATE SQL VIEW view4 as SELECT c,3 FROM byby &?(cWhere1+cWhere2) && execute fire a  error here

CLOSE DATABASES
CLOSE TABLES ALL
DELETE DATABASE test
Fabio
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform