postgres problem with serial

dagl3 - July 1, 2009 - 21:03

hi,
I've these table:
CREATE TABLE registro
(
usuario character varying(100) NOT NULL,
cargo character varying(100) NOT NULL,
proyecto character varying(100),
actividad integer NOT NULL,
fecha date NOT NULL,
dia integer NOT NULL,
semana integer NOT NULL,
ano integer NOT NULL,
tiempo real NOT NULL,
id_registro serial NOT NULL,
CONSTRAINT registro_pkey PRIMARY KEY (id_registro))

The pk is the serial id_registro, it's was working properly, but after a time didn't work, for the last regitry, id_registro was in 64992 and something happened because when I tried to insert the return was duplicate keys, cuolud be taht the sequence was lost, i want to know what happened with the table..... what was the problem....

the solution i fonud was the use of select setval('sequence', number) and now its working properly but itcolud ocurrs again and i dont want to repeat the problem, any one knows why this happened?????

 
 

Drupal is a registered trademark of Dries Buytaert.