Обсуждение: Bug with serial columns
If I execute "psql database < file.sql"
where file.sql contents are as follow below.
last_value it does not get update after inserts.
I have several options :
CREATE SEQUENCE START 9 or
SELECT SETVAL('fam_idfam_seq', 9);
Why if I execute the sentences directly from psql it works ok?
It seems to be a bug, doesn't it ?
CREATE TABLE fam (
idfam serial,
nombre varchar(60) not null,
descrip text,
PRIMARY KEY (idfam)
);
INSERT INTO fam (idfam,nombre) VALUES ( 1, 'TEM' );
INSERT INTO fam (idfam,nombre) VALUES ( 2, 'ESC' );
INSERT INTO fam (idfam,nombre) VALUES ( 3, 'EXP');
INSERT INTO fam (idfam,nombre) VALUES ( 4, 'STA');
INSERT INTO fam (idfam,nombre) VALUES ( 5, 'AME');
INSERT INTO fam (idfam,nombre) VALUES ( 6, 'VOL);
INSERT INTO fam (idfam,nombre) VALUES ( 7, 'FAL');
INSERT INTO fam (idfam,nombre) VALUES ( 8, 'CAR');
INSERT INTO fam (idfam,nombre) VALUES ( 9, 'ELE');
-- Evelio Martínez Testanet. Dept. desarrollo software. Av. Reino de Valencia, 15 - 5 46005 Valencia (Spain) Tel: +34 96 395 90 00 Fax: +34 96 316 23 19
Insert your values with out the idfam in them, i.e.: INSERT INTO fam (nombre) VALUES ('TEM'); INSERT INTO fam (nombre) VALUES ('ESC'); INSERT INTO fam (nombre) VALUES ('EXP'); INSERT INTO fam (nombre) VALUES ('STA'); INSERT INTO fam (nombre) VALUES ('AME'); INSERT INTO fam (nombre) VALUES ('VOL'); INSERT INTO fam (nombre) VALUES ('FAL'); INSERT INTO fam (nombre) VALUES ('CAR'); INSERT INTO fam (nombre) VALUES ('ELE'); Michael Fork - CCNA - MCP - A+ Network Support - Toledo Internet Access - Toledo Ohio On Wed, 31 Jan 2001, Evelio Martinez wrote: > Hi! > If I execute "psql database < file.sql" > where file.sql contents are as follow below. > > last_value it does not get update after inserts. > > I have several options : > CREATE SEQUENCE START 9 or > SELECT SETVAL('fam_idfam_seq', 9); > > Why if I execute the sentences directly from psql it works ok? > It seems to be a bug, doesn't it ? > > > CREATE TABLE fam ( > idfam serial, > nombre varchar(60) not null, > descrip text, > PRIMARY KEY (idfam) > ); > > INSERT INTO fam (idfam,nombre) VALUES ( 1, 'TEM' ); > INSERT INTO fam (idfam,nombre) VALUES ( 2, 'ESC' ); > INSERT INTO fam (idfam,nombre) VALUES ( 3, 'EXP'); > INSERT INTO fam (idfam,nombre) VALUES ( 4, 'STA'); > INSERT INTO fam (idfam,nombre) VALUES ( 5, 'AME'); > INSERT INTO fam (idfam,nombre) VALUES ( 6, 'VOL); > INSERT INTO fam (idfam,nombre) VALUES ( 7, 'FAL'); > INSERT INTO fam (idfam,nombre) VALUES ( 8, 'CAR'); > INSERT INTO fam (idfam,nombre) VALUES ( 9, 'ELE'); > > > > > > -- > Evelio Mart�nez > Testanet. Dept. desarrollo software. > Av. Reino de Valencia, 15 - 5 > 46005 Valencia (Spain) > Tel: +34 96 395 90 00 > Fax: +34 96 316 23 19 > > >