Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Expression as parameter
Message
De
14/10/2000 13:41:13
 
 
À
13/10/2000 22:56:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00428475
Message ID:
00429525
Vues:
16
>>CREATE SQL VIEW lvMyView AS SELECT * FROM mytable WHERE &?lcWhere
>>Then the WHERE can be whatever you want it to be....
>>
>>Just make sure the & is in front of the ?
>
>Have you tried this - I get a syntax error if I don't pre-populate lcWhere, regardless of the value for lcWhere, even ".T." - I can't even modify the view definition, getting a Syntax error. It will fire if I pre-populate lcWhere with a string that macro-expands to a simple logical; I can' modify the view properties, or requery it if the pre-populated value goes out-of-scope. It also gets upset if I add clauses after the logical. I can however:
>
>CREATE SQL VIEW lvMyView AS SELECT * FROM mytable WHERE EVAL(?lcWhere)

Yep - tried it and even use it in apps.

I can't get EVAL() to actually work once the view is defined. I get "Field xxx not found" errors.

The macro'd version of this view will NOT be able to created/modified in the view designer. It only works in code. I abandoned the view designer a long time ago, so I always forget to mention it :)

Coding the view works, however. Try this, e.g.:
LOCAL ji, ldDate
CLOSE DATA ALL
RELEASE vpc_Where
IF !FILE("testme.dbc")
  CREATE DATA testme
  CREATE TABLE testme (cfield c(10), dfield d)
  FOR ji = 1 TO 60
    ldDate = {^2000-09-01}
    INSERT INTO testme VALUES (CDOW(ldDate+ji), ldDate+ji)
  ENDFOR
ELSE
  OPEN DATA testme
ENDIF

CREATE SQL VIEW lv_testme AS SELECT * FROM testme WHERE &?vpc_Where

vpc_Where = "cfield = 'Sunday'"
USE lv_testme
BROWSE

vpc_Where = "MONTH(dfield)=10 AND DAY(dfield)%2=0"
REQUERY()
BROWSE

? DBGETPROP("lv_testme", "view", "sql")
Insanity: Doing the same thing over and over and expecting different results.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform