Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select * using SPT returning duplicate records
Message
From
26/06/2003 13:06:00
 
 
To
26/06/2003 10:48:07
Joel Leach
Memorial Business Systems, Inc.
Tennessee, United States
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00804056
Message ID:
00804310
Views:
36
Hi Joel,
Yes Matt and John are still with ARI and all is going well. I am maintaining the new version of Feldar21 and still creating reports which seems like a never ending task. Not much of the original Feldar97 remains except for the name and some of the report layouts. Feldar21 was built as client server app with a choice of databases via ODBC connection to VFP, Oracle, or SQL Server backend data store. All data access is via RV's and SPT.

What started this was that I needed to get a copy of one user's database that is stored in SQL server and they had no clue or permissions to do a backup of the database to send it to me, so I thought I would just copy all data records to a VFP copy of the database and have them send that to me. It worked fine testing it with a SQL server backend, but testing against a VFP source database gave me these sporatic dups.

I will check out the fetch in background setting to see if it makes a difference. What is really weird is that it does not happen in the same records or even the same table every time. And substituting RV's in the same code in place of SPT using the same DSN does not get the duplicate records.

>Hi Elmer,
>
>I ran this on one of my data sets and I got the same problem. I turned off Fetch Data in Background in the ODBC driver, and that seemed to eliminate the duplicates. You may be able to do this in code, but I'm not sure since I don't use SPT. The table I had a problem with copied 372,000 records. Unfortunately, the source table is 382,000 records. This might just be a problem with my data, but you should probably double-check your record counts.
>
>BTW, it's good to see some of my code is in the new system. Of course, it is only the first six letters of the DBC name, but I'll take what I can get. <g> Seriously though, how's life at ARI these days? Are John and Matt still working there?
>
>>I wrote a procedure today to copy data from an ODBC database to another empty VFP database with the same tables and structures to get a copy of data from SQL server to a VFP database for testing. Basically, I created a VFP database with empty tables for the copy and used SPT to "SELECT *" from each table in the source database into a cursor, then append from the cursor into the matching table in the copy database. Not an elegant solution but a very simple one (or so I thought).
>>
>>This worked well when copying data from a SQL Server database to a VFP database, but when I tested it using a VFP source database, on several tables, seemingly at random, the SPT query gets the correct record count from the source table, but when I append from the cursor, I get a "Uniqueness of primary key violation" error and the append fails. I have checked it out and the source VFP table does not have duplicate records, but the "select *" SPT cursor does. I have validated the database and recreated all indexes. What is happening is that the SPT cursor is duplicating several records in the result set when I "select * " from the source table using SPT. It does not happen on the same table or same records when running the program over and over.
>>
>>I created a dbc with remote views that "Select *" from the source and run the same procedure using the RV's and it gets all records, with no error, every time. There are about 63 tables in the database ranging in size from a few records to over 400,000 records. All tables have primary keys and do not have duplicate records.
>>
>>This concerns me as I use SPT all the time to get cursors for reporting (though not using Select *) but I am now concerned that I may not be getting correct results. I am using VFP 6 SP5.
>>
>>I have created a couple of test programs with data that will demonstrate this very strange behavior. With the source database it is pretty large even zipped (41 MB) but if anyone is interested in checking it out, I have a FTP site where you can download it. Let me know and I will set it up for download.
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform