Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I test for empty cursor
Message
From
02/10/2007 22:44:46
Hee Lim Wang
Fantasy Software Enterprise
Malaysia
 
 
To
01/10/2007 08:16:33
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01257479
Message ID:
01258129
Views:
21
>>>>How do Determine if a cursor is empty after doing select statement. The following is not working:
>>>>
>>>>

>>>> Select crsprod, crsitemcode, sum(crsrequestamt) as inreq, sum(crsaccptamt) as whsaccpt, crsdelivertype, Count(*) as duplicate From crs_grid1 ;
>>>> Group By crsprod, crsitemcode, crsdelivertype HAVING duplicate > 1 AND crsdelivertype > 1 INTO CURSOR crs_find_dup
>>>> IF isnull('crs_find_dup')
>>>> MESSAGEBOX('empty cursor',0,'')
>>>> ELSE
>>>> MESSAGEBOX('not empty cursor',0,'')
>>>> ENDIF
>>>>

>>>>
>>>>thanks
>>>>Nick
>>>
>>>After your SELECT, check _TALLY=0.
>>
>>thanks Fred, that worked.
>>
>>Nick
>PMFJI, Nick,
>
>That may not work in vfp9, because _tally returns a 1 because of the sum().
>You may need to do something like this in vfp 9:
>

> SELECT SUM(capacity) AS capacity ;
> FROM cVehCap ;
> WHERE loadtype == lcType ;
> INTO ARRAY latmp1
> IF !ISNULL(latmp1) AND !EMPTY(latmp1)
>

In order to check if a cursor is empty, what I started doing in VFP9 is:

GO TOP
IF !BOF()
* do whatever
ELSE
* empty cursor
ENDIF


i always check with eof() without go top
select * form mytable into cursor mycursor where...........
if eof()
?'no data !'
return
endif
Previous
Reply
Map
View

Click here to load this message in the networking platform