Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wildcard in SPT
Message
From
14/05/2010 07:58:18
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
14/05/2010 07:08:56
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01464542
Message ID:
01464545
Views:
36
>Is there any way to do a wildcard on the tsosan field in the where section? I know that the table field data will not have the 'A" but I still need a match on the part number.
>
>
>
>testconnString= "Select recseq From webprddt7.tsotagtbl" +;
>" Where cono = '225907' And tsosan in('862708-401A','862708-402A','862708-403A'," +;
>"'862708-404A','862709-401A','862709-402A','862711-401A','862712-401A','862714-401A','862715-401A','862716-401A')"
>
>
>
Steven,
Using In is not ideal IMHO. In real life you shouldn't be really hardcoding all these values, do you? If so you can then write it like:
text to m.lcSQL noshow
Select recseq 
From webprddt7.tsotagtbl
 Where cono = '225907' And 
   (tsosan LIKE '862708-401%' or
    tsosan LIKE '862708-402%' or
   ...)
endext
If not then sending those values to SQL server and creating a table variable is a better solution IMHO. ie:
Text to lcSQL noshow
DECLARE @myVals TABLE (VALUE VARCHAR(20))
INSERT @myVals ( VALUE ) VALUES  ('862708-401')
INSERT @myVals ( VALUE ) VALUES  ('862708-402')
-- ...

Select recseq 
From webprddt7.tsotagtbl
inner join @myVals ON tsosan LIKE [@myVals].VALUE+'%'
 Where cono = '225907'
endtext
SQLExec(m.handle, m.lcSQL)
If your list is very long then you could also go for a better performing 'send comma separated list and parse to table on server' approach.
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
Reply
Map
View

Click here to load this message in the networking platform