Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ciprian Zaharia
  Where is Ciprian Zaharia?
 Brossard
 Canada
 Ciprian Zaharia
 To: Chris J
  Where is Chris J?
 
 United Kingdom
 Chris J
 Tags
Subject: RE: "Uniqueness violated" on SYS(2015)
Thread ID: 248724 Message ID: 248741 # Views: 3 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Tuesday, December 22, 2009 8:37:07 PM         
   


> I have a routine that looks (roughly) like this:
>
>
SELECT a
> SCAN
> 
>     SCATTER NAME o BLANK
>     SELECT b
>     && assign various values to o based on fields in a
>     o.rec_id = SYS(2015)
> 
>     IF NOT ISNULL(o.importantfield)
>         APPEND BLANK
>         GATHER NAME o
>     ENDIF
>     SELECT a
> ENDSCAN

>
> After running through a few hundred records, I get a "uniqueness violated" error. I check the index reported, and it is a candidate key index on a single field - rec_id, which for every record in the table contains a value obtained from SYS(2015).
>
> Thoughts?

When I cannot use autoinc like Boris said I'm using this function to generate unique names
Function HDSN  && function to generate a unique string based on serial number of harddisk and vfp function sys(2015)
          ofs=Create('scripting.filesystemobject')
          HDSN=Transform(ofs.drives('C').serialnumber, "@0x")+Sys(2015)
          Return HDSN


It is generating unique names for each computer but if you execute fast enough you can still make duplicates
on the same computer.

See also if you don't get the error because of append blank


Ciprian Zaharia
Fox4Ever
http://www.visitmix.com/Opinions/Why-Does-Your-Code-or-Design-Suck
http://genn.org/stuff/tastes/

ENTIRE THREAD

"Uniqueness violated" on SYS(2015) Posted by Chris J @ 12/22/2009 5:15:18 PM
RE: "Uniqueness violated" on SYS(2015) Posted by Borislav Borissov @ 12/22/2009 5:37:31 PM
RE: "Uniqueness violated" on SYS(2015) Posted by Chris J @ 12/29/2009 11:44:45 AM
RE: "Uniqueness violated" on SYS(2015) Posted by Anders Altberg @ 12/29/2009 3:57:23 PM
RE: "Uniqueness violated" on SYS(2015) Posted by Ciprian Zaharia @ 12/22/2009 8:37:07 PM
RE: "Uniqueness violated" on SYS(2015) Posted by Jun Tangunan @ 12/23/2009 1:15:49 AM
RE: "Uniqueness violated" on SYS(2015) Posted by Anatoliy Mogylevets @ 12/23/2009 5:39:50 PM
RE: "Uniqueness violated" on SYS(2015) Posted by Anders Altberg @ 12/25/2009 6:35:13 PM