Program Code giving duplicate errors where no duplicates exist

  • On our Java Hibernate program it is giving a duplicate value on an insert on a table where there are no values remotely close to the vales being inserted. The developers have stepped through their code, connecting  from other source code, though the program has not changed in 2 years. Running the insert directly in sql works perfectly. The code works fine in another environment, when we restore the production database to another environment it fails with the same error. On this environment we did a reorg of the index, recreated the index, did a full consistency check on the db with dbcc checkdb including indexes and fond nothing. We are totally out of ideas what to do next

    • This topic was modified 4 months, 4 weeks ago by  Andre 425568.
  • If you can recreate the issue in a test environment, can you try removing the index, performing the problematic insert & then looking at the results?

    Or could the source data itself contain dupes?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Is the duplicate column an identity column or using a sequence? If so, are the current values behind the actual values in the database?

  • and is the insert a single statement inserting single row values or is it the result of joining other tables - including the possibility of being done on a merge statement where some rows change value (which would remove the duplicate error) and a new row is inserted?

  • Problem resolved, was a odd glitch in code that did not copy data from  from an order through to the GRN, you had to  reapply the order details, then the data tried writing to the wrong table as it it did not see the data. I am still confused why it caused a duplicate though. Apparently it writes 2 journal records to the other table which does not have the Unique index.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply