Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing primary keys to a View with an in filter
Message
From
18/07/2002 20:23:47
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00679658
Message ID:
00680277
Views:
26
>Hi - is it possible to use a view to return records that match the primary keys in a list?
>I have a view with this SQL
>
>SELECT *;
> FROM youthbase!ygprojects;
> WHERE Ygprojects.pj_primary IN (?vRange)
>
>
>I have tried passing it...
>strRange = "17,66,89"
>vRange = &strRange
>vRange = evaluate(strRange)
>but neither work - sometimes I get an error and sometimes I just get the first record returned
>
>If I put the values directly in the view I get the 3 records back OK
>
>Any ideas greatly appreciated

This will work but it's kind of ugly...

CREATE SQL VIEW testsub as select * from clients where pk_clients in (select pk_clients from cClientList)

You just have to populate the subquery table before using the view, which you could do with a cursor created just for that purpose, e.g.:

create cursor cClientList (pk_clients i)
insert into cClientList values (103)
insert into cClientList values (259)
insert into cClientList values (31245)

requery('testsub')

etc..

-Rick
Previous
Reply
Map
View

Click here to load this message in the networking platform