Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 To: Cecil Champenois
  Where is Cecil Champenois?
 Little Elm
 Texas - United States
 Cecil Champenois
 Tags
Subject: RE: LOCATE FOR
Thread ID: 416437 Message ID: 416469 # Views: 45 # Ratings: 2
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Tuesday, December 30, 2014 2:23:08 AM         
   


> 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.


Just for fun:

Create Cursor mysql_emails (lfound l, attachment c(3), recvd_dt d)
Insert Into mysql_emails Values (.F.,':A:',Date())
Insert Into mysql_emails Values (.F.,':B:',Date())
Insert Into mysql_emails Values (.F.,':C:',Date())

Create Cursor kmartsearsfiles2012 (filename c(1), msg_dt d)
Insert Into kmartsearsfiles2012 Values ('B',Date())

Local lcAttachment, lcMessageDate, lnCount
Select mysql_emails
Scan
	lcAttachment = attachment
	lcMessageDate = recvd_dt
	Select filename From kmartsearsfiles2012 Where ;
		':'+Alltrim(filename)+':' = m.lcAttachment And msg_dt = m.lcMessageDate ;
		Into Cursor junk NOFILTER
	If _Tally > 0
		Replace mysql_emails.lfound With .T.In mysql_emails
	Endif
Endscan
Browse



Also, whether you use LOCATE or something like the above, better perform the SCAN...ENDSCAN on the table with least record. If you notoced above i performed it on MySQL_Emails and not on KMART..., guessing it has less records.


https://vfpx.codeplex.com/releases/view/99045
http://sandstorm36.blogspot.com

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