Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error when creating a cursor.

Status
Not open for further replies.

Niki_S

Programmer
Jun 4, 2021
232
LK
I have a table as C:\TEMPFILES\abc and I passed my table data into a cursor like this.
Code:
SELECT * FROM 	abc INTO CURSOR _ACPgrn

And then I used my table and passed some records to another table.
Code:
SELECT cUser,cBatchNo,cFact ,cSupplier,cType, cAdNumber , dAdDate ,cPayNumber , cBatchCurr ,nAdValue FROM C:\TEMPFILES\abc ;
GROUP BY cUser,cBatchNo,cFact ,cSupplier,cType, cAdNumber , dAdDate ,cPayNumber , cBatchCurr ,nAdValue INTO CURSOR ACP

And I used these codes.
Code:
SELECT * FROM _ACPgrn  INTO TABLE C:\TEMPFILES\BatchV
SELECT nBatchId,cBatchNo  FROM BatchV GROUP BY nBatchId,cBatchNo  INTO CURSOR _Batchv

when I run my form I got this error.
'_ACPGRN' must be created with INSERT...INTO TABLE

What is this and how can I fix this?
 
For what reason do you create _ACPgrn as a complete copy of abc? and then again copy _ACPgrn to BatchV?

In the end BatchV is bc, isn't it? I guess you're omitting soe code here that may explain the use of multiple names for the same data, but from what you show this could be simplified to
Code:
SELECT cUser,cBatchNo,cFact ,cSupplier,cType, cAdNumber , dAdDate ,cPayNumber , cBatchCurr ,nAdValue FROM C:\TEMPFILES\abc ;
GROUP BY cUser,cBatchNo,cFact ,cSupplier,cType, cAdNumber , dAdDate ,cPayNumber , cBatchCurr ,nAdValue INTO CURSOR ACP 

SELECT nBatchId,cBatchNo  FROM abc GROUP BY nBatchId,cBatchNo  INTO CURSOR _Batchv

Chriss
 
Well, and looking into both GROUP BY, grouping by all fields you select just means creating distinct records, you're not really grouping records here? Do you understand what group by does? It's not for sorting records into groups, it's for aggregating data to one record per group. To make sense of it you'd have some aggregation function used within the field list, like COUNT(), SUM(), AVG(), MIN() or MAX().

Chriss
 
The issue is that your first cursor doesn't actually have its own disk presence. It's just a filtered version of the original table. VFP does that when a query includes only one table, and is entirely optimizable. Add NOFILTER at the end and you'll get a real cursor and the rest should work.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top