>Hello everyone,
>
>I have many small tables with different names but identical structure, my task is to extract some data from each of them and append into a cursor. The only way I can do this is to save the data from small tables into an array, then put them into the cursor, but I feel this not the best way, I want to transfer the data directly but not through the array.
>
>The way I want to do is:
>
>Create Cursor MyCursor
>FileList=adir(SmallTable_xx.dbf)
>
>For each SmallTable in FileList
> Extract useful data from SmallTable
> Insert the data into the Cursor
>Endfor
>
>
>
>Is it possible to open 2 tables at the same time, then put the data from one to another? If yes, would someone please teach me how? Or any other suggestions?
>
>Thanks in advance!!
Hi Jimi,
You are probably going to have to use one array and then do an INSERT since VFP's INSERT SQL command does not do a 'INSERT INTO tablename (SELECT * from AnotherTableName)'
Of course you can open 2 tables or more at the same time. Use SQL statements in your loop thus;
Create Cursor MyCursor (yourfieldname1 type precision, ...)
ADIR(FileList, 'SmallTable_*.dbf')
*-- ALEN() will give you the row count of the array fileList
For x=1 to ALEN(FileList,1)
*-- Open the table in an unused work area
USE FileList[x,1] IN 0
*-- Extract your data
SELECT yourFields
FROM (FileList[x,1])
WHERE yourSelectCondition
INTO ARRAY dataArray
*-- Insert the data into the Cursor
INSERT INTO DBF('MyCursor') FROM ARRAY dataArray
*-- Close files and clean up
Endfor
Sanjay Kapoor
Relatively speaking is a conversation with Einstein