Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Argie Badua
  Where is Argie Badua?
 Banna, Ilocos Norte
 Philippines
 Argie Badua
 To: Lou Harris
  Where is Lou Harris?
 Kansas City
 Kansas - United States
 Lou Harris
 Tags
Subject: RE: DO WHILE in a cursor problem
Thread ID: 21927 Message ID: 21988 # Views: 1 # Ratings: 0
Version: Visual FoxPro 7 Category: General VFP Topics
Date: Monday, April 07, 2003 9:51:09 AM         
   


> > Does anyone know why my do while !EOF() loop will only do the first record and then exit even though there are alot more records in the source cursor?
> >
> >
> >   SELECT lineno, sono, item, loctid, qtyord-qtyshp AS qtyord, picked, whmap, RECNO("a") AS recno ;
> >     FROM (m0sotranf) a WHERE sono = lc_sono AND sostat=' ' AND sotype$" O" ;
> >     ORDER BY 1 INTO CURSOR C_first
> > bROW  
> >   GO TOP
> >   DO WHILE !EOF()  && Will only go through first record then exit
> >   	  ln_memcount = MEMLINES(whmap)-1
> >   	  *IF ln_memcount > 1
> >   	  FOR i = 1 TO ln_memcount
> >   	  
> >   	    lc_str      = MLINE(whmap, i)
> >   	    lc_chkitem  = SUBSTR(lc_str, 1, 15)
> >   	    lc_pickloc1 = SUBSTR(lc_str, 16, 6)
> >   	    lc_pickq1   = VAL(SUBSTR(lc_str, 22, 5))
> >   	    lc_vndid1   = SUBSTR(lc_str, 27, 6)
> >   	    lc_pickloc2 = SUBSTR(lc_str, 33, 6)
> >   	    lc_pickq2   = VAL(SUBSTR(lc_str, 39, 5))
> >   	    lc_vndid2   = SUBSTR(lc_str, 44, 6) 
> >     	
> >     	SELECT a_tmpf1 
> >   	  
> >   	    APPEND BLANK
> >   	    REPLACE Lineno WITH c_first.lineno, ITEM WITH c_first.item, BOM WITH lc_chkitem, LOCTID WITH c_first.loctid, ;
> >   	            QTY WITH c_first.qtyord, pickloc1 WITH lc_pickloc1, pickq1 WITH lc_pickq1, VndID1 WITH lc_vndid1,;
> >   	            pickloc2 WITH lc_pickloc2, pickq2 WITH lc_pickq2, VndID2 WITH lc_vndid2
> >   	    REPLACE oqty WITH qty, opickloc1 WITH pickloc1, opickq1 WITH pickq1, OVndID1 WITH VndID1;
> >   	            opickloc2 WITH pickloc2, opickq2 WITH pickq2, OVndID2 WITH VndID2, recno WITH c_first.recno
> >   	
> >       ENDFOR
> >       *ENDIF
> >   SKIP
> >   ENDDO
> > 

>
> Would it run okay with this simple modification? (added the SELECT C_first statement after the REPLACE statements)
>
>
> SELECT lineno, sono, item, loctid, qtyord-qtyshp AS qtyord, picked, whmap, RECNO("a") AS recno ;
> FROM (m0sotranf) a WHERE sono = lc_sono AND sostat=' ' AND sotype$" O" ;
> ORDER BY 1 INTO CURSOR C_first
> bROW 
> GO TOP
> DO WHILE !EOF() && Will only go through first record then exit
>     ln_memcount = MEMLINES(whmap)-1
>     *IF ln_memcount > 1
>     FOR i = 1 TO ln_memcount
> 
>     lc_str = MLINE(whmap, i)
>     lc_chkitem = SUBSTR(lc_str, 1, 15)
>     lc_pickloc1 = SUBSTR(lc_str, 16, 6)
>     lc_pickq1 = VAL(SUBSTR(lc_str, 22, 5))
>     lc_vndid1 = SUBSTR(lc_str, 27, 6)
>     lc_pickloc2 = SUBSTR(lc_str, 33, 6)
>     lc_pickq2 = VAL(SUBSTR(lc_str, 39, 5))
>     lc_vndid2 = SUBSTR(lc_str, 44, 6) 
> 
>    SELECT a_tmpf1 
> 
>     APPEND BLANK
>     REPLACE Lineno WITH c_first.lineno, ITEM WITH c_first.item, BOM WITH lc_chkitem, LOCTID WITH c_first.loctid, ;
>     QTY WITH c_first.qtyord, pickloc1 WITH lc_pickloc1, pickq1 WITH lc_pickq1, VndID1 WITH lc_vndid1,;
>     pickloc2 WITH lc_pickloc2, pickq2 WITH lc_pickq2, VndID2 WITH lc_vndid2
>     REPLACE oqty WITH qty, opickloc1 WITH pickloc1, opickq1 WITH pickq1, OVndID1 WITH VndID1;
>     opickloc2 WITH pickloc2, opickq2 WITH pickq2, OVndID2 WITH VndID2, recno WITH c_first.recno
> 
>    && change work area back to SQL - SELECTed cursor. 
>    SELECT C_first 
> 
> ENDFOR
> *ENDIF
> SKIP
> ENDDO
> 
> 

>
>
> Lou Harris
> lharris@epiqsystems.com
> Software Engineer, EPIQ Systems, Inc.
> http://www.epiqsystems.com


Maybe you can replace CONTINUE instead of SKIP, so it will continue to search until the EOF. Hope it helps...:)

Argie S. Badua

COMPLETE THREAD

DO WHILE in a cursor problem Posted by bleech67 toms @ 4/4/2003 5:02:05 PM
RE: DO WHILE in a cursor problem Posted by bleech67 toms @ 4/4/2003 5:28:19 PM
RE: DO WHILE in a cursor problem Posted by bleech67 toms @ 4/4/2003 6:05:06 PM
RE: DO WHILE in a cursor problem Posted by Michael Gill @ 4/4/2003 6:41:21 PM
Use SCAN ALL instead of DO WHILE Posted by Ken Blum @ 4/4/2003 6:42:10 PM
RE: Use SCAN ALL instead of DO WHILE Posted by Michael Gill @ 4/4/2003 6:51:13 PM
RE: Use SCAN ALL instead of DO WHILE >> michael Posted by bleech67 toms @ 4/4/2003 7:09:13 PM
RE: Use SCAN ALL instead of DO WHILE >> michael Posted by Michael Gill @ 4/4/2003 8:17:09 PM
RE: Use SCAN ALL instead of DO WHILE >> BTW Posted by bleech67 toms @ 4/4/2003 10:19:33 PM
For Michael - SCAN - ENDSCAN Select Posted by Ken Blum @ 4/7/2003 4:30:06 PM
RE: For Michael - SCAN - ENDSCAN Select Posted by Michael Gill @ 4/7/2003 4:57:21 PM
LOL Posted by bleech67 toms @ 4/4/2003 9:53:08 PM
RE: DO WHILE in a cursor problem Posted by Lou Harris @ 4/5/2003 2:14:22 AM
RE: DO WHILE in a cursor problem Posted by Argie Badua @ 4/7/2003 9:51:09 AM