Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a conditional 'where' clause
Message
From
03/06/1999 20:38:18
 
 
To
03/06/1999 15:33:38
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00226172
Message ID:
00226337
Views:
24
>I am trying to create a remote view (from SQL Server back end) that would emulate the following Passthrough code:
>
>
IF gcFunction = '001'
>  sqlexec(handle, 'select * from p1', 'p1')
>ELSE
>  sqlexec(handle, 'select * from p1 where p1_funckey = {gcfunction}', 'p1')
>ENDIF
>
>In other words, I want all records if the value of gcFunction is '001', otherwise I want to filter for p1_funckey equaling the value of gcFunction. I have already tried a variety of IIF() constructs in the where clause, but that doesn't work. How do I do this?
>
>Thanks

You can do this by creating your remote view via code... you can't creat or open this view in the view designer...

create sql view MyView remote share as 'select * from p1 where &lcwhere'

Now that you have the remote view created, you just have to make sure that you populate a private variable lcWhere with your where. So, for the situation above you might have code like...
if gcFunction = '001'
   lcWhere = '.t.'
else
   lcWhere = 'p1_funckey = @gcfunction'
endif

use MyView
Let me know if this works... I am not sure if it is exactally right... this technique was in a FoxAdvisor last year.

BOb
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform