Re: [GENERAL] Duplicate Unique Key constraint error

2007-07-12 Thread Alvaro Herrera
Harpreet Dhaliwal escribió: > How can one rollover a sequence back to zero after you delete records from > a > table with one such sequence. > I see it starting with the last value of the sequence inserted. You can use setval(), but normally you just leave it alone. Having numbers not starting f

Re: [GENERAL] Duplicate Unique Key constraint error

2007-07-12 Thread Harpreet Dhaliwal
How can one rollover a sequence back to zero after you delete records from a table with one such sequence. I see it starting with the last value of the sequence inserted. On 7/11/07, Tom Allison <[EMAIL PROTECTED]> wrote: On Jul 10, 2007, at 3:09 PM, Tom Lane wrote: > > "Harpreet Dhaliwal" <

Re: [GENERAL] Duplicate Unique Key constraint error

2007-07-11 Thread Tom Allison
On Jul 10, 2007, at 3:09 PM, Tom Lane wrote: "Harpreet Dhaliwal" <[EMAIL PROTECTED]> writes: Transaction 1 started, saw max(dig_id) = 30 and inserted new dig_id=31. Now the time when Transaction 2 started and read max(dig_id) it was still 30 and by the time it tried to insert 31, 31 was a

Re: [GENERAL] Duplicate Unique Key constraint error

2007-07-10 Thread Harpreet Dhaliwal
Thanks alot for all your suggestions gentlemen. I changed it to a SERIAL column and all the pain has been automatically alleviated :) Thanks a ton. ~Harpreet On 7/10/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Harpreet Dhaliwal" <[EMAIL PROTECTED]> writes: > Transaction 1 started, saw max(dig_id)

Re: [GENERAL] Duplicate Unique Key constraint error

2007-07-10 Thread Tom Lane
"Harpreet Dhaliwal" <[EMAIL PROTECTED]> writes: > Transaction 1 started, saw max(dig_id) = 30 and inserted new dig_id=31. > Now the time when Transaction 2 started and read max(dig_id) it was still 30 > and by the time it tried to insert 31, 31 was already inserted by > Transaction 1 and hence the

Re: [GENERAL] Duplicate Unique Key constraint error

2007-07-10 Thread Michael Glaesemann
On Jul 10, 2007, at 13:22 , Harpreet Dhaliwal wrote: Transaction 1 started, saw max(dig_id) = 30 and inserted new dig_id=31. Now the time when Transaction 2 started and read max(dig_id) it was still 30 and by the time it tried to insert 31, 31 was already inserted by Transaction 1 and hence

Re: [GENERAL] Duplicate Unique Key constraint error

2007-07-10 Thread Harpreet Dhaliwal
I lately figured out the actual problem PHEW. Its something like two different transactions are seeing the same snapshot of the database. Transaction 1 started, saw max(dig_id) = 30 and inserted new dig_id=31. Now the time when Transaction 2 started and read max(dig_id) it was still 30 and by the

Re: [GENERAL] Duplicate Unique Key constraint error

2007-07-10 Thread Harpreet Dhaliwal
my primary key is neither SERIAL nor a SEQUENCE. CONSTRAINT pk_dig PRIMARY KEY (dig_id) This is the clause that I have for my primary key in the create table script. thanks, ~Harpreet On 7/10/07, Ron St-Pierre <[EMAIL PROTECTED]> wrote: Harpreet Dhaliwal wrote: > Hi, > > I keep getting this

Re: [GENERAL] Duplicate Unique Key constraint error

2007-07-09 Thread Ron St-Pierre
Harpreet Dhaliwal wrote: Hi, I keep getting this duplicate unique key constraint error for my primary key even though I'm not inserting anything duplicate. It even inserts the records properly but my console throws this error that I'm sure of what it is all about. Corruption of my Primary Ke

[GENERAL] Duplicate Unique Key constraint error

2007-07-09 Thread Harpreet Dhaliwal
Hi, I keep getting this duplicate unique key constraint error for my primary key even though I'm not inserting anything duplicate. It even inserts the records properly but my console throws this error that I'm sure of what it is all about. Corruption of my Primary Key can be one of the possibili