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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COPY TO ARRAY results in truncated results

Status
Not open for further replies.

jonblack

Programmer
Nov 25, 2008
11
US
I have an ODBC result cursor that has 6000+ rows reported. I am trying to feed it into a VFP9 table.

My plan was simple:
Code:
<LOOP for tables>
  <ODBC query run here>
  COPY TO ARRAY aname
  SELECT table
  APPEND FROM ARRAY aname
<ENDLOOP>

My problem is that the array only loads 2748 records. After testing I found that the array size was fixed to the record count of the first table loop. I had to add a "RELEASE aname" statement at the end of the loop.

Code:
<LOOP for tables>
  <ODBC query run here>
  COPY TO ARRAY aname
  SELECT table
  APPEND FROM ARRAY aname
  RELEASE aname
<ENDLOOP>

VFP9 did not re-dimension the array once it was created. After adding the RELEASE statement the process worked as expected.

Jon B
 
If the array exists before copy to array it is neither created nor redimensioned again. You have to release it or dimension it yourself to get correct reccount items.

However, you could use:
Code:
local array arrData[1]
Select * from myODBCCursor into array arrData

Select SQL, unlike copy to array, creates the array as needed and/or redimensions it as needed.

But, since you have a cursor at hand, I don't see the logic behind doing it like:

Code:
COPY TO ARRAY aname
SELECT table
APPEND FROM ARRAY aname

Why don't you instead simply append from cursor or use 'Insert into ... select ...'.

Array would consume unnecessary memory and would probably be slower in this case.


Cetin Basoz
MS Foxpro MVP, MCP
 
Answer: BRAIN FREEZE

Ok, color me blushing. I totally forgot about using:
Code:
append from DBF("cursorname")
I was stuck in a different mindset. This was a good exercise none the less as I had the same issue with another array in the code that I could not do without.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top