-
1. Re: Coldfusion unexplainable duplicate issues, cannot figure this out!
irvirv1 Oct 25, 2014 9:05 AM (in response to jeculture)Hello. I know it's been awhile but did you figure this out? I have a very similar thing happening. Something along the lines of
INSERT INTO WorkSheet (CODE_KEY)
SELECT TOP (1) EI.CODE_KEY
FROM EmpInfo AS EI LEFT OUTER JOIN
WorkSheet AS WS ON WS.CODE_KEY = EI.CODE_KEY
WHERE (EI.CODE_KEY = 'param1') AND (WS.CODE_KEY IS NULL)
where the field "CODE_KEY" is a the primary key in SQL Server 2008. This is similar to what you're doing except that the check for an existing value happens as part of the insert query. Just like you every once in awhile I get the "[Macromedia][SQLServer JDBC Driver][SQLServer]Violation of PRIMARY KEY constraint" error. I'd say I get one a week.
The only hint I have is that there is an insert that succeeds. This insert happens at the same time as the one that fails. That seems that the code is executing twice at the exact same time which seems impossible. In fact it seems to me that a second query would have to happen so fast that the join shows no value (otherwise I'd get records updated = 0 rather than the error) but then the first (successful) record is created prior to the 2nd one being inserted.
-
2. Re: Coldfusion unexplainable duplicate issues, cannot figure this out!
WolfShade Oct 27, 2014 5:58 AM (in response to jeculture)The most likely scenario is that the form is submitting twice (I am gathering that from the fact that you are having CF generate the UUID in the form and submitting it as part of the process instead of letting the DB do it.)
If you are using jQuery or any other form of AJaX to submit the form, this is a fairly frequent issue.
php - Why is my form submitting twice? - Stack Overflow
My form submit is called twice (HTML, CSS and JavaScript forum at JavaRanch)
One click on a form submits twice! | Coding Forums
Another common mistake is to have both the FORM and JavaScript do the submitting (ie, the form has a submit button that when clicked calls a function for form validation that also submits the form.)
Check to make sure that none of the above scenarios applies to your situation. If that's not the case, then let us know.
HTH,
^_^
-
3. Re: Coldfusion unexplainable duplicate issues, cannot figure this out!
irvirv1 Oct 31, 2014 8:33 AM (in response to WolfShade)Mine (October 25 above) gets the same error but note that the key value is not passed in as a direct "insert value [key]" but rather a a select value [key] from another table where value [key] does NOT exist within the table being inserted into. In theory even if I submitted form twice (or more) the first submit should return 1 row updated and the next one(s) 0 rows updated. Or at least that's what I'm thinking should happen. As an aside, this is a straight form submit.
Irv

