Re: [SQL] INSERT w/o variable names for a SERIAL type?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Emils Klotins <emils(at)mail(dot)usis(dot)bkc(dot)lv>, pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] INSERT w/o variable names for a SERIAL type?
Date: 2000-02-27 18:58:43
Message-ID: 200002271858.NAA00857@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

[Charset ISO-8859-1 unsupported, filtering to ASCII...]
> Emils Klotins writes:
>
> > Now, if I want to write a general #define, I'd need to have a way
> > to specify 'default' for SERIAL field, for, if I omit the id field in
> > VALUES, I need to specify all the rest of the fields explicitly.
> >
> > Is there any value I could put in place of id in VALUES part, to
> > make it replaced with the next value in sequence?
>
> INSERT INTO my_table VALUES (a, b, c, DEFAULT, x, y, z, ...);

I didn't think that worked, and it doesn't seem to work. Should it?

test=> create table j(x serial, y char(10))\g
NOTICE: CREATE TABLE will create implicit sequence 'j_x_seq' for SERIAL
column 'j.x'
NOTICE: CREATE TABLE/UNIQUE will create implicit index 'j_x_key' for
table 'j'
CREATE
test=> insert into j values (default,'yes');
ERROR: parser: parse error at or near "default"

--
Bruce Momjian | http://www.op.net/~candle
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2000-02-27 19:04:42 Re: [SQL] INSERT w/o variable names for a SERIAL type?
Previous Message Tom Lane 2000-02-27 18:29:21 Re: [SQL] INSERT w/o variable names for a SERIAL type?