Does a parameterized CREATE SQL VIEW have to take the form shown
in VFP Help and MSDN Library:
Value = "Value"
CREATE SQL VIEW lvTable ;
AS SELECT Fields ;
FROM Table ;
WHERE Field = ?Value
or can it be in this form:
Condition = "Field = 'Value'"
CREATE SQL VIEW lvTable ;
AS SELECT Field1, Field2 ;
FROM Table ;
WHERE ?Condition
I actually want to build a condition like this, where the user may
enter values for one or more of four fields, then click cmdFind:
Condition = ""
IF NOT EMPTY(m.MemVar1)
Condition = "Field1 = m.MemVar1"
ENDIF
IF NOT EMPTY(m.MemVar2)
IF NOT EMPTY(m.Condition)
Condition = m.Condition + " AND "
ENDIF
Condition = m.Condition + "Field2 = m.MemVar2"
ENDIF
IF NOT EMPTY(m.MemVar3)
IF NOT EMPTY(m.Condition)
Condition = m.Condition + " AND "
ENDIF
Condition = m.Condition + "Field3 = m.MemVar3"
ENDIF
IF NOT EMPTY(m.MemVar4)
IF NOT EMPTY(m.Condition)
Condition = m.Condition + " AND "
ENDIF
Condition = m.Condition + "Field4 = m.MemVar4"
ENDIF
IF EMPTY(m.Condition)
=MESSAGEBOX("No criteria entered", 0+64+0, "Query error")
THISFORM.Refresh
ELSE
CREATE SQL VIEW lvTable ;
AS SELECT t1.*, t2.Descript, t3.Name ;
FROM Table1 t1, CodeTable1 t2, CodeTable2 t3 ;
WHERE t2.ID = t1.t2ID AND t3.ID = t1.t3ID ;
AND ?Condition
*!* This SQL SELECT works, but I want an updatable view!
*!* Yeah, I know I should probably have used EVAL instead of macro.
*!* SELECT t1.*, t2.Descript, t3.Name ;
*!* FROM Table1 t1, Codes t2, Names t3 ;
*!* WHERE t2.ID = t1.CodeID AND t3.ID = t1.NameID ;
*!* AND &Condition ;
*!* ORDER BY 4, 3 ;
*!* INTO CURSOR lvTable
TIA,
RichRich Addison, Micro Vane, Inc., Kalamazoo, MI
Relax, don't worry, have a homebrew.
- Charlie Papazian, The New Complete Joy of Home Brewing