Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Wildcard in SPT
Message
De
14/05/2010 07:58:18
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
14/05/2010 07:08:56
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01464542
Message ID:
01464545
Vues:
37
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform