Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 To: Chris J
  Where is Chris J?
 
 United Kingdom
 Chris J
 Tags
Subject: RE: "Uniqueness violated" on SYS(2015)
Thread ID: 248724 Message ID: 248758 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Wednesday, December 23, 2009 1:15:49 AM         
   


> 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?


Sys(2015) on itself is not always unique. To ensure uniqueness, you should combine it with another thing like seconds():

?SYS(2015)+TRANSFORM(INT(SECONDS()))


But I would prefer Integer AutoInc usage.

Jun Tangunan
http://weblogs.foxite.com/sandstorm36/default.aspx
http://www.coderisland.com/forum/viewforum.php?f=10

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