>>
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.