Re: [SQL] INSERT w/o variable names for a SERIAL type? - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: [SQL] INSERT w/o variable names for a SERIAL type?
Date
Msg-id 200002271858.NAA00857@candle.pha.pa.us
Whole thread Raw
In response to Re: [SQL] INSERT w/o variable names for a SERIAL type?  (Peter Eisentraut <peter_e@gmx.net>)
List 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))\gNOTICE:  CREATE TABLE will create implicit sequence 'j_x_seq' for
SERIALcolumn'j.x'NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'j_x_key' fortable 'j'CREATEtest=> insert into
jvalues (default,'yes');ERROR:  parser: parse error at or near "default"
 

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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: [SQL] INSERT w/o variable names for a SERIAL type?
Next
From: Bruce Momjian
Date:
Subject: Re: [SQL] INSERT w/o variable names for a SERIAL type?