Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQL Select command into cursor

236 views
Skip to first unread message

char

unread,
Jun 23, 2009, 3:39:01 PM6/23/09
to
Hi,

I use SQL Select command into cusor A and set grid.recordsource="A".
However, since SQL select command gets nothing so there is no data in A. I
would like to add MESSAGEBOX() to be shown before it goes to empty grid
(there is no data in cursor A) but I have tried empty(),isnull() and
isblank() and received "variable A not found. Is there a way I can check if
cursor is empty or not? I am using select count(*) into array B and
?empty(B) for the evaluation as alternative.

Thanks for your time.
Char

Rush Strong

unread,
Jun 23, 2009, 5:21:59 PM6/23/09
to

A couple of options:

- Quick and dirty: Immediately after the SQL Select, check the
value of _TALLY:
SELECT [yada yada] INTO CURSOR MyCursor
lEmpty = _TALLY = 0

_TALLY is an internal counter used for various purposes by Fox,
including the number of records in a SQL Select. But it has to be
tested immediately, because other commands may change it!

- More general solution, IF there are no deleted records:

lEmpty = RECCOUNT(MyCursor) = 0

Note that RECCOUNT() will count deleted records, whether SET DELETED
is ON or OFF.

Also, I hope you aren't actually using 'A' and 'B' as cursor names,
as they refer to work areas 1 and 2 by default. That is, if you:

CLOSE DATA ALL

USE Table1 IN 0 && Table1 is opened in work area 1
USE Table2 IN 0 && Table2 is opened in work area 2
SELECT Table2 && work are 2 is selected

* The following will all return the value of Table1.Field1:
? Table1.Field1
? A.Field1

SELECT 1
? Field1

[Specifying alpha or numerical work areas is no longer good coding
practice, but sill works for the sake of backward compatibility.]

- Rush

char

unread,
Jun 24, 2009, 8:56:01 PM6/24/09
to
Thank You Rush.
0 new messages