Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parameterized Views
Message
From
28/11/1999 22:10:08
 
 
To
28/11/1999 21:50:28
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00296038
Message ID:
00296251
Views:
21
>>>Hello everyone,
>>>I would like to know how to pass a parameter to a view's "where" clause for conditions. For example, in different areas I may have different "where" clause conditions. In one instance, I may have "cField1 = 'x'" and in another instance "cField2 = 'y' .AND. !empty(cField1)". Is this possible? I had attempted the following but it did not work: "create sql view test as select * from myTable where ?x"
>>>then before issuing the "use test" I assigned x="cField1 = 'x'". I would appreciate any suggestions.
>>
>>Others have responded to this question and I agree with all of them.
>>
>>You could use an open clause
>>
>>cExpr = "cField1 = 'x'"
>>
>>CREATE SQL VIEW "My_view" ;
>> AS SELECT field_list from my_table ;
>> where &cExpr
>>
>>This may blow up in your face though. Not having defined cExpr and trying to use the view in a form will error, all the time.
>>
>>__Stephen
>What if you select NoDataOnLoad? then put a value in cExpr then do a REQUERY()?
>
>Would that not work??

The problem is that the macro will be resolved to a literal expression when the CREATE SQL VIEW executes.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform