Issue: Insert duplicate records in table

  • Hi,

    I'm not sure this is the right SQL forum for posting an issue that I'm having. I'm using SQL Server 2000 database in a Java environment using JDBC driver 2005.

    One in awhile I see duplicate records in one of my database tables which I inserted records into. The duplicate record got inserted a few milliseconds after the first one.

    Here's an example of my insert statement.

           INSERT INTO ra_review_t (srvc_request_num,

                                    review_level,

                                    decision_id,

                                    rationale_id,

                                    comments,

                                    complaint_num,

                                    experience_num,

                                    review_count,

                                    reviewed_by,

                                    reviewed_dt,

                                    last_updated_by,

                                    last_updated_dt)

            VALUES ('123', 

                        1,

                        1,

                        2,

                        'test comments',

                        '1232',

                        '1333',

                        1,

                        'byme',

                       GETDATE(),

                        'byme',

                        GETDATE())

    Has any one encounter this issue in SQL 2000 database?

    Thanks,

    Tuan

  • It's your application issue.

    Quite typical issue.

    Remove duplicated roudtrip to database for saving data.

    You may check that double call takes place using SQL Profiler.

    _____________
    Code for TallyGenerator

  • And Set a Primary Key on the table so that the app fails when it tries a second time


    * Noel

  • Hi Sergiy and Noel -

    THanks for your responses and help with this issue. A work around solution for now is to set the primary key on the right column to prevent duplication.

    THanks again,

    Tuan

  • I fail to understand why a primary key is ever a "workaround"!

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

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