Re: [GENERAL] serial type - Mailing list pgsql-general

From Charles Tassell
Subject Re: [GENERAL] serial type
Date
Msg-id 4.1.19990928031028.00942ba0@mailer.isn.net
Whole thread Raw
In response to [GENERAL] serial type  (Greg Beams <gob@cat.cs.mu.OZ.AU>)
List pgsql-general
What is the syntax you are using for the insert?

This:

INSERT INTO comment VALUES (, 'Example');

or this

INSERT INTO comment (rec_id, locale) VALUES (, 'Example');

won't work.  You have to *specifically* leave out the sequence field in
your field list, like this:

INSERT INTO comment (locale) VALUES ('Example');

It works the same for any default value, which is basically what a sequence
is (type sequence = int default nextval('sequence') )

At 01:45 AM 9/28/99, Greg Beams wrote:
>I'm trying to create a table as such:
>
>create table comment
>(rec_id serial,
>locale varchar(50),
>...)
>
>It creates correctly, telling me that it will create an implicit sequence
>for the serial column, and an implicit index for the table.  But, when I
>try to insert a record into the database (without specifying the value for
>the rec_id column) I get the following error:
>
>ERROR:  serial.nextval: sequence does not exist
>
>Does anyone have any ideas (I'm not sure whether this belongs on this
>list, or the pgsql-sql list)?
>
>Thanks, Greg.
>
>Greg Beams - gob@students.cs.mu.oz.au
>
>I'M NOT OKAY, YOU'RE NOT OKAY--BUT, HEY, THAT'S OKAY.
>
>
>************
>


pgsql-general by date:

Previous
From: greg@proterians.net
Date:
Subject: Re: [GENERAL] backend crashing with INTERSECT / ORDER BY
Next
From: Holger Klawitter
Date:
Subject: 6.5.2 unter Solaris 2.6 feedback