Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IN question
Message
From
02/09/2005 06:08:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
01/09/2005 18:41:18
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01046060
Message ID:
01046132
Views:
18
This message has been marked as a message which has helped to the initial question of the thread.
>Hi All:
>
>I have a table - Test - that contains 4 records, as follows:
>
>
>Code    Desc
>111     Dog
>222     Cat
>333     Elephant
>444     Fish
>
>
>I want to give the user the ability to query on a variable number of code or 'ALL' the codes.
>
>In the following example, she has picked '111' and '222', so I constructed an array in the calling program with a length of 2. If she would have requested '111', '222', and '444', I would have had to construct an array of 3 members and some figured out how to accommodate
>the third member in my SQL syntax. If she requests all, then I need to set one of the members to ‘’ and since everything is equal to ‘’, all for records will be returned.
>
>Isn’t there a more elegant way to do this?
>
>
>
>LPARAMETERS taCodeList
>* taCodeList[1] = '111'
>* taCodeList[2] = '222'
>
>SELECT Test.code, Test.Desc ;
> FROM Test ;
>   WHERE Test.code IN(taCodeList[1],taCodeList[2]) ;
>   INTO CURSOR result
>
>
>Thanx,
>
>Yossi

Use a cursor.
lparameters taCodeList
create cursor crsItems (itemcode c(10))
dimension taCodeList[alen(taCodeList),1]
insert into crsItems from array taCodeList

SELECT Test.code, Test.Desc ;
 FROM Test ;
   inner join crsItems itm on test.code == itm.itemcode ;
   INTO CURSOR result
use in 'crsItems'
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform