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: Mustapha Bihmouten
  Where is Mustapha Bihmouten?
 Casablanca
 Morocco
 Mustapha Bihmouten
 Tags
Subject: RE: SCAN WHILE not working with conditions
Thread ID: 331077 Message ID: 331087 # Views: 36 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Monday, December 26, 2011 5:46:57 PM         
   


> >
> > I may do that, since it appears to not be working. What I am seeing is that the SCAN doesn't move, or doesn't seem to move.
> >
> > ...a little later...
> > I decided to make a few changes and the program is now working properly. I removed part of the scan conditions and just put them into an IF condition. This seems to work better. I could not "overload" scan because it could not seem to handle the load.
> >
> > IF m.CHILD AND SEEK(m.GrpID+m.GrpNum, "GRPEXTDP", "FULL_KEY")
> > 	SELECT GRPEXTDP
> > 	SCAN WHILE GrpExtDP.GrpID+GrpExtDP.GrpNum=m.GrpID+m.GrpNum
> > 		*IF EVALUATE([LEFT(RelateCd, 1) $ "C,D"] + lcCondition)
> > 		IF LEFT(RelateCd,1) $ 'C,D' &lcCondition
> > 		* List variables and their sources.
> > 			m.Seq=GRPEXTDP.Seq			&& Dependent's Sequence #
> > 			IF .chk9DigitSSN.Value = 1	&& Show all 9-digits of Dependent's SSN.
> > 				m.SSN=tmpResults.SS_Number	&& Employee's SSN
> > 			ELSE
> > 				* Employee's Last 4-digits of SSN.
> > 				m.SSN=SUBSTR(tmpResults.SS_Number, 6, 4)
> > 			ENDIF
> > 			*m.SSN      =tmpResults.SS_Number	&& Employee's SSN
> > 			m.LastName =tmpResults.LastName	&& Employee's Surname
> > 			m.FirstName=tmpResults.FirstName	&& Employee's First Name
> > 			m.DepLName =GRPEXTDP.LastName		&& Dependent's Surname
> > 			m.DepFName =GRPEXTDP.FirstName		&& Dependent's First Name
> > 			m.Eff_Date =GRPEXTDP.EffDate		&& Dependent's Effective Date
> > 			m.TermDate =GRPEXTDP.TermDate		&& Dependent's Term Date.
> > 			m.Relation =GRPEXTDP.Relation		&& Daughter, Son, Child
> > 			INSERT INTO cDetail FROM MEMVAR
> > 		ENDIF
> > 	ENDSCAN
> > ENDIF	&& child
> > 

> > Cecil Champenois, Jr.
>
>
> be aware that evaluate() is "evaluated" once and only once in the scan : "scan while evaluate( ...)"
> with you modification it is evaluated at each loop ...
>
> Regards
> Mustapha Bihmouten

I really didn't know that. I didn't read that in the documentation anywhere, but I believe you, which might explain why it would only give me one of the children dependents from the loop. Thanks Mustapha.

I can see by the remarks that EVALUATE() is not any good for SQL statements either:

Remarks

EVALUATE( ) is similar to TYPE( ) but returns the result of an expression instead of the expression type. An expression containing EVALUATE( ) cannot be optimized by Rushmore Query Optimization.

Including the EVALUATE( ) function in the WHERE clause of a SQL query can return incorrect data.

Cecil Champenois, Jr.

ENTIRE THREAD

SCAN WHILE not working with conditions Posted by Cecil Champenois @ 12/26/2011 4:35:13 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/26/2011 4:57:18 PM
RE: SCAN WHILE not working with conditions Posted by Cecil Champenois @ 12/26/2011 5:04:12 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/26/2011 5:34:11 PM
RE: SCAN WHILE not working with conditions Posted by Cecil Champenois @ 12/26/2011 5:46:57 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/27/2011 11:34:01 AM
RE: SCAN WHILE not working with conditions Posted by Martin Krivka @ 12/27/2011 12:57:21 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/27/2011 1:41:37 PM
RE: SCAN WHILE not working with conditions Posted by Martin Krivka @ 12/27/2011 1:56:58 PM
RE: SCAN WHILE not working with conditions Posted by Anil Sharma @ 12/27/2011 1:59:29 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/27/2011 2:27:28 PM
RE: SCAN WHILE not working with conditions Posted by tushar @ 12/27/2011 2:40:27 PM
RE: SCAN WHILE not working with conditions Posted by Martin Krivka @ 12/27/2011 4:41:41 PM
RE: SCAN WHILE not working with conditions Posted by tushar @ 12/26/2011 7:42:37 PM
RE: SCAN WHILE not working with conditions Posted by Anil Sharma @ 12/26/2011 8:19:52 PM