Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use a Predefined List for At command
Message
 
 
To
26/04/2007 15:14:08
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01220224
Message ID:
01220239
Views:
23
>My list could get large, maybe 30 words.
>
>Here is a piece of code:
>
>
>getPSString = "SELECT cinbr, itdsc, ittyp FROM amflib6.pstruc" +;
>" Join amflib6.itemasa On amflib6.itemasa.itnbr = amflib6.pstruc.cinbr" +;
>" Where pinbr = '" + testQuery.cdaitx + "'"
>
>=SQLEXEC(testconn, getPSString, 'getPSQuery')
>
>SELECT getPSQuery
>	
>SCAN FOR AT("TOOL", getPSQuery.itdsc) < 1 AND  AT("MO-ISSUE", getPSQuery.itdsc) < 1
>		
>INSERT INTO psCursor(itemid, rellev, partno, descptn, faiid, faistatus) ;
>Values(x, '1', getPSQuery.cinbr, getPSQuery.itdsc, "", "")
>
In other words, you only want to get records that don't have specific words in them, right?

Try something like this (from the top of my head and not tested)
create cursor curUnwantedWords(cWord C(20))
populate the cursor with your list

select my.* from getPSQuery my inner join curUnwantedWords cur ;
on my.itdsc LIKE '%' + alltrim(cur.cWord) + '%' ;
into cursor curMatched

INSERT INTO psCursor(itemid, rellev, partno, descptn, faiid, faistatus) ;
select ... from getPSQuery my left join curMatched cur on my.PK = cur.PK where cur.PK is null
*>Values(x, '1', getPSQuery.cinbr, getPSQuery.itdsc, "", "")

Another alternative would be to construct your where clause as a string and macro execute it, e.g.
lcList = [MyFirsWord,MySecondWord,MyLastWord]
=alines(laWords,lcList,.t.,',')
lcWhere = ""
for lnI = 1 to alen(laWords,1)
   lcWhere = m.lcWhere + " AND not '" + laWords[m.lnI] + "' $ cDescr"
next

insert into myFinalResult (...) select ... from myTempResult where 1=1 &lcWhere
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform