Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cecil Champenois
  Where is Cecil Champenois?
 Little Elm
 Texas - United States
 Cecil Champenois
 To: Mike Yearwood
  Where is Mike Yearwood?
 Toronto
 Canada
 Mike Yearwood
 Tags
Subject: RE: LOCATE FOR
Thread ID: 416437 Message ID: 416453 # Views: 38 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Monday, December 29, 2014 9:35:06 PM         
   


> > I am beginning to doubt if FoxPro can handle a compound search when using LOCATE FOR. Any insight on this? I am using the following code with indexing and don't see that it's working:
> >
> > SELECT KMartSearsFiles2012
> > SCAN
> > 	* Get the string. We will need to parse this string out.
> > 	* The file names are separated with":" at the beginning,
> > 	* and the end of each file.
> > 	lcAttachment=":" + ALLTRIM(KMartSearsFiles2012.FileName) + ":"
> > 	lcMessageDate=KMartSearsFiles2012.Msg_Dt
> > 	SELECT MySQL_Emails
> > 	LOCATE FOR ;
> > 		MySQL_Emails.Recvd_Dt = lcMessageDate AND ;
> > 		lcAttachment $ MySQL_Emails.Attachment
> > 	IF FOUND()
> > 		REPLACE MySQL_Emails.lFound WITH .T.
> > 	ENDIF
> > ENDSCAN
> > 

> >
> > Cecil Champenois, Jr.
>
> LOCATE certainly can be used in a second alias inside a SCAN. If you have a Recvd_Dt index it will speed up quite a bit.
> Are you sure you have to use $ to match the filename?
>
>
> SELECT KMartSearsFiles2012
> SCAN
> 	* Get the string. We will need to parse this string out.
> 	* The file names are separated with":" at the beginning,
> 	* and the end of each file.
> 	lcAttachment=":" + UPPER(ALLTRIM(KMartSearsFiles2012.FileName)) + ":"
> 
> 	SELECT MySQL_Emails
> 	LOCATE FOR ;
> 		Recvd_Dt = KMartSearsFiles2012.Msg_Dt AND ;
> 		m.lcAttachment $ UPPER(Attachment)
> 	IF FOUND()
> 		REPLACE lFound WITH .T. IN MySQL_Emails
> 	ENDIF
> 	*No need to select KMartSearsFiles alias, as that is implicit in the SCAN.
> ENDSCAN
> 

>
> Mike Yearwood
> Microsoft MVP Visual FoxPro 2008, 2009
> We have enough youth. We need a fountain of smart!
> There may be many ways to skin a cat, but there are very few right ways to do it.

Well, I found another way to hit this. I didn't like it that there could be one or more file names inside the memo field called Attachment in the MySQL_Emails table, so I parsed out that table so that the separate file names in the memo field became new records in another table. This worked.

Cecil Champenois, Jr.

ENTIRE THREAD

LOCATE FOR Posted by Cecil Champenois @ 12/29/2014 6:34:17 PM
RE: LOCATE FOR Posted by Pete Sass @ 12/29/2014 7:11:17 PM
RE: LOCATE FOR Posted by Cecil Champenois @ 12/29/2014 9:38:00 PM
RE: LOCATE FOR Posted by Greg Green @ 12/29/2014 9:57:36 PM
RE: LOCATE FOR Posted by Pete Sass @ 12/29/2014 11:16:15 PM
RE: LOCATE FOR Posted by Mike Yearwood @ 12/30/2014 3:49:07 PM
RE: LOCATE FOR Posted by Pete Sass @ 12/30/2014 6:18:31 PM
RE: LOCATE FOR Posted by Mike Yearwood @ 12/30/2014 6:55:18 PM
RE: LOCATE FOR Posted by Mike Yearwood @ 12/29/2014 8:30:51 PM
RE: LOCATE FOR Posted by Cecil Champenois @ 12/29/2014 9:35:06 PM
RE: LOCATE FOR Posted by Tony Vignone @ 12/29/2014 9:03:34 PM
RE: LOCATE FOR Posted by Greg Green @ 12/29/2014 10:03:17 PM
RE: LOCATE FOR Posted by Tony Vignone @ 12/30/2014 3:27:40 PM
RE: LOCATE FOR Posted by David Myrick @ 12/29/2014 10:21:05 PM
RE: LOCATE FOR Posted by Jun Tangunan @ 12/30/2014 2:23:08 AM