Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2006

    Unanswered: nextval and wrong id

    How this code

    insert into "analyse" values (nextVal('analyse_id_seq'),'someinfo');

    can out smth like this :

    ERROR: duplicate key violates unique constraint "analysePK"

    I'm pretty new to postgres so any help will be appreciate


  2. #2
    Join Date
    Mar 2006


    Ok i'm working with Spring and IBatis and it seems to come from that sorry for the post, admin you can clean it.

    Thank you !

  3. #3
    Join Date
    Jun 2004
    Arizona, USA
    I'm glad that you figured out where the error was coming from.

    As a general guideline, assuming that the first field in table analyse is the PK, the only way that wyat you observed could have happened is that the Sequence analyse_id_seq was recreated or altered before the insert took place, and that data inserted using the old sequence was still in the table. (Or, that data in the analyze table was altered so that IT would interfere with subsequent inserts...)

    When altering a sequence, you must take care that the starting point for the sequence will not create new values that are already present in the table(s) where the sequence is applied.
    Last edited by loquin; 03-23-06 at 16:56.
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts