Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Cecil Champenois
  Where is Cecil Champenois?
 Little Elm
 Texas - United States
 Cecil Champenois
 Tags
Subject: RE: Two conditions in IF Statement
Thread ID: 345461 Message ID: 345466 # Views: 51 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Wednesday, May 23, 2012 3:31:29 PM         
   


> >
> > What does it do?
> >
> > PS: You can also write that as an update (replace with the key expression instead of full_key):
> >
> >
Update tmpCursorABQ ;
> >  set SpouseFN = GRPEXTDP.FirstName, ;
> > 	SpouseIn  = GRPEXTDP.Initial, ;
> > 	SpouseLN  = GRPEXTDP.LastName, ;
> > 	SpouseDOB = DTOS(GRPEXTDP.DOB) ;
> >  from GRPEXTDP ;
> >  where tmpCursorABQ.GrpID+tmpCursorABQ.GrpNum = GRPEXTDP.Full_Key

> >
> >

> > Cetin Basoz
> >
> > .Net has got better.Think about moving - check my blog:
> > My Blog
> > Blog (mirror) - sounds to be down
> >

> > Support Wikipedia
>
> The following code seems to do the job:
>
> SELECT tmpCursorABQ
> SCAN
> 	* If there is a Spouse, get the Name and Date of Birth and put this data
> 	* into the above cursor.
> 	lcID=tmpCursorABQ.GrpID+tmpCursorABQ.GrpNum
> 	IF SEEK(lcID, "GRPEXTDP", "FULL_KEY")
> 		SELECT GRPEXTDP
> 		LOCATE WHILE GRPEXTDP.GRPID+GRPEXTDP.GRPNUM=lcID FOR LEFT(GRPEXTDP.Relatecd,1)="S"
> 		IF FOUND()
> 			REPLACE ;
> 				tmpCursorABQ.SpouseFN  WITH GRPEXTDP.FirstName, ;
> 				tmpCursorABQ.SpouseIn  WITH GRPEXTDP.Initial, ;
> 				tmpCursorABQ.SpouseLN  WITH GRPEXTDP.LastName, ;
> 				tmpCursorABQ.SpouseDOB WITH DTOS(GRPEXTDP.DOB)
> 		ENDIF
> 	ENDIF
> ENDSCAN
> 

>
> Cecil Champenois, Jr.

That makes sense (first found might not be Spouse). You can actually write it more efficiently replacing locate with scan. Like:

SELECT tmpCursorABQ
SCAN
	* If there is a Spouse, get the Name and Date of Birth and put this data
	* into the above cursor.
	lcID=tmpCursorABQ.GrpID+tmpCursorABQ.GrpNum
	IF SEEK(m.lcID, "GRPEXTDP", "FULL_KEY")
		Select grpextdp
		Scan while WHILE GRPEXTDP.GRPID+GRPEXTDP.GRPNUM=m.lcID for LEFT(GRPEXTDP.Relatecd,1)="S"
		REPLACE ;
			tmpCursorABQ.SpouseFN  WITH GRPEXTDP.FirstName, ;
			tmpCursorABQ.SpouseIn  WITH GRPEXTDP.Initial, ;
			tmpCursorABQ.SpouseLN  WITH GRPEXTDP.LastName, ;
			tmpCursorABQ.SpouseDOB WITH DTOS(GRPEXTDP.DOB) in 'tmpCursorABQ'
		EndScan
		SELECT tmpCursorABQ
	ENDIF
EndScan


But again, IMHO update version is simpler and more effective:

Update tmpCursorABQ ;
 set SpouseFN = GRPEXTDP.FirstName, ;
	SpouseIn  = GRPEXTDP.Initial, ;
	SpouseLN  = GRPEXTDP.LastName, ;
	SpouseDOB = DTOS(GRPEXTDP.DOB) ;
 from GRPEXTDP ;
 where tmpCursorABQ.GrpID+tmpCursorABQ.GrpNum = GRPEXTDP.GRPID+GRPEXTDP.GRPNUM and LEFT(GRPEXTDP.Relatecd,1)="S"

* more likely you have indexes on GrpId and GrpNum - better than concatting
* where tmpCursorABQ.GrpID = GRPEXTDP.GRPID and tmpCursorABQ.GrpNum = GRPEXTDP.GRPNUM ;
*    and LEFT(GRPEXTDP.Relatecd,1)="S"




Cetin Basoz

.Net has got better.Think about moving - check my blog:
My Blog
Blog (mirror) - sounds to be down


Support Wikipedia

ENTIRE THREAD

Two conditions in IF Statement Posted by Cecil Champenois @ 5/23/2012 3:01:21 PM
RE: Two conditions in IF Statement Posted by Cetin Basoz @ 5/23/2012 3:15:26 PM
RE: Two conditions in IF Statement Posted by Cecil Champenois @ 5/23/2012 3:19:33 PM
RE: Two conditions in IF Statement Posted by Cetin Basoz @ 5/23/2012 3:31:29 PM
RE: Two conditions in IF Statement Posted by Mike Yearwood @ 5/23/2012 4:43:26 PM