Using Recno() in a query.
Hello, BraileyD!
You wrote on 7 Apr 2003 06:57:22 -0800:
B> Select * From HugeTable;
B> Where Recno('HugeTable') BETWEEN (61000 AND 100000) ;
B> Into cursor SecondGroup
B> I end up with no records in the result. Is there something I should
B> know about using Recno() as part of a query? How can I make this work,
B> and make it work quickly?
The SQL is wrong.
Select * From HugeTable;
Where BETWEEN (Recno('HugeTable') , 61000, 100000) ;
Into cursor SecondGroup
or
Select * From HugeTable;
Where Recno('HugeTable') BETWEEN 61000 AND 100000 ;
Into cursor SecondGroup
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
# 1 Re: Using Recno() in a query.
Sorry Eric, neither of those queries will work.
Leave the alias argument out of the RECNO() command when using in a query.
Also, you will not be able to use the RECNO() function at all if there is
more than one table involved in the query.
So the queries should be:
Select * From HugeTable;
Where Recno() BETWEEN (61000 AND 100000) ;
Into cursor SecondGroup
See the VFP help for SELECT - SQL for more details.
--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
Eric den Doop wrote:
> Hello, BraileyD!
> You wrote on 7 Apr 2003 06:57:22 -0800:
>
>> Select * From HugeTable;
>> Where Recno('HugeTable') BETWEEN (61000 AND 100000) ;
>> Into cursor SecondGroup
>
>> I end up with no records in the result. Is there something I should
>> know about using Recno() as part of a query? How can I make this
>> work, and make it work quickly?
>
> The SQL is wrong.
>
> Select * From HugeTable;
> Where BETWEEN (Recno('HugeTable') , 61000, 100000) ;
> Into cursor SecondGroup
>
> or
>
> Select * From HugeTable;
> Where Recno('HugeTable') BETWEEN 61000 AND 100000 ;
> Into cursor SecondGroup
> --
> Eric den Doop
> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By
> VFP8
--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.467 / Virus Database: 266 - Release Date: 4/1/2003
# 2 Re: Using Recno() in a query.
I need to break a huge table into chunks that will fit on a single sheet of
an Excel spreadsheet. When I attempt to use:
Select * From HugeTable;
Where Recno('HugeTable') BETWEEN (61000 AND 100000) ;
Into cursor SecondGroup
I end up with no records in the result. Is there something I should know
about using Recno() as part of a query? How can I make this work, and make
it work quickly?
Thanks for your help
# 3 Re: Using Recno() in a query.
Hello, Fred!
You wrote on Mon, 7 Apr 2003 07:49:18 -0700:
FT> Sorry Eric, neither of those queries will work.
No need to say sorry. You are right (for most of the part) and I was wrong
(for most of the part).
I checked back with my test code and found that the SQL will work, only if
the table has not already been opened. Try this:
CLOSE ALL
SELECT * ;
FROM (HOME() + "samples\tastrade\data\customer") ;
WHERE RECNO("customer") between 1 AND 5 ;
INTO CURSOR tmp
?_tally
This works fine only the first time. If you re-run the query (customer is
opened automatically by the previous query), it does not return the 5
records. Anyway, one cannot rely on code like this, so thanks for the
correction.
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
# 4 Re: Using Recno() in a query.
Thanks to both of you guys. Now it works just fine with my single
huge list of EPA pesticides. Now I can get on to using OLE to dump it into
an Excel sheet. For some reason I just had the thought that I'd be coming
back with a question on OLE. Just a feeling...
"Fred Taylor" <ftaylor@mvps.org> wrote:
>Sorry Eric, neither of those queries will work.
>
>Leave the alias argument out of the RECNO() command when using in a query.
>Also, you will not be able to use the RECNO() function at all if there is
>more than one table involved in the query.
>
>So the queries should be:
>
> Select * From HugeTable;
> Where Recno() BETWEEN (61000 AND 100000) ;
> Into cursor SecondGroup
>
>
>See the VFP help for SELECT - SQL for more details.
>
>--
>
>Fred
>Microsoft Visual FoxPro MVP
>Please respond only to the newsgroups so that all may benefit.
>
>
>
>
>Eric den Doop wrote:
>> Hello, BraileyD!
>> You wrote on 7 Apr 2003 06:57:22 -0800:
>>
>>> Select * From HugeTable;
>>> Where Recno('HugeTable') BETWEEN (61000 AND 100000) ;
>>> Into cursor SecondGroup
>>
>>> I end up with no records in the result. Is there something I should
>>> know about using Recno() as part of a query? How can I make this
>>> work, and make it work quickly?
>>
>> The SQL is wrong.
>>
>> Select * From HugeTable;
>> Where BETWEEN (Recno('HugeTable') , 61000, 100000) ;
>> Into cursor SecondGroup
>>
>> or
>>
>> Select * From HugeTable;
>> Where Recno('HugeTable') BETWEEN 61000 AND 100000 ;
>> Into cursor SecondGroup
>> --
>> Eric den Doop
>> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By
>> VFP8
>
>
>--
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.467 / Virus Database: 266 - Release Date: 4/1/2003
>
>
# 5 Re: Using Recno() in a query.
USE sometable
_VFP.DataToClip(,,3)
ox = CREATEOBJECT('Excel.Application')
ox.Workbooks.Add()
ox.ActiveSheet.Paste()
ox.ActiveWorkbook.SaveAs("c:\test.xls")
ox.Quit()
ox = null
--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
BraileyD wrote:
> Thanks to both of you guys. Now it works just fine with my single
> huge list of EPA pesticides. Now I can get on to using OLE to dump it
> into an Excel sheet. For some reason I just had the thought that I'd
> be coming back with a question on OLE. Just a feeling...
>
> "Fred Taylor" <ftaylor@mvps.org> wrote:
>> Sorry Eric, neither of those queries will work.
>>
>> Leave the alias argument out of the RECNO() command when using in a
>> query. Also, you will not be able to use the RECNO() function at all
>> if there is more than one table involved in the query.
>>
>> So the queries should be:
>>
>> Select * From HugeTable;
>> Where Recno() BETWEEN (61000 AND 100000) ;
>> Into cursor SecondGroup
>>
>>
>> See the VFP help for SELECT - SQL for more details.
>>
>> --
>>
>> Fred
>> Microsoft Visual FoxPro MVP
>> Please respond only to the newsgroups so that all may benefit.
>>
>>
>>
>>
>> Eric den Doop wrote:
>>> Hello, BraileyD!
>>> You wrote on 7 Apr 2003 06:57:22 -0800:
>>>
>>>> Select * From HugeTable;
>>>> Where Recno('HugeTable') BETWEEN (61000 AND 100000) ;
>>>> Into cursor SecondGroup
>>>
>>>> I end up with no records in the result. Is there something I
>>>> should know about using Recno() as part of a query? How can I make
>>>> this
>>>> work, and make it work quickly?
>>>
>>> The SQL is wrong.
>>>
>>> Select * From HugeTable;
>>> Where BETWEEN (Recno('HugeTable') , 61000, 100000) ;
>>> Into cursor SecondGroup
>>>
>>> or
>>>
>>> Select * From HugeTable;
>>> Where Recno('HugeTable') BETWEEN 61000 AND 100000 ;
>>> Into cursor SecondGroup
>>> --
>>> Eric den Doop
>>> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By
>>> VFP8
>>
>>
>> --
>> Outgoing mail is certified Virus Free.
>> Checked by AVG anti-virus system (http://www.grisoft.com).
>> Version: 6.0.467 / Virus Database: 266 - Release Date: 4/1/2003
--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.467 / Virus Database: 266 - Release Date: 4/1/2003
