From: Alessio Bragadini <alessio@albourne.com>
To: Emils Klotins <emils@mail.usis.bkc.lv>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] INSERT w/o variable names for a SERIAL type?
Date: Fri, 25 Feb 2000 17:14:26 +0200
Message-ID: <38B69C52.11EEF672@albourne.com> (raw)
References: <200002251428.QAA06635@www.usis.bkc.lv>
Emils Klotins wrote:
> I am using, which is written for connecting to another server
> and uses the AUTO_INCREMENT and BLOB fields (for storing
> text). Apparently it was written for mysql(?).
Most probably.
> I wanted to write a #define or two to change the relevant
> places, such as
>
> #define IDKEY "INTEGER AUTO_INCREMENT PRIMARY
> KEY" // mysql version
> #define IDKEY "SERIAL PRIMARY KEY" // postgres
Note that SERIAL is syntactic sugar for
INT4 NOT NULL DEFAULT NEXTVAL('<table>_<field>_SEQ')
> INSERT INTO mytable VALUES (NULL, 'textvalue');
> and NULL would get translated into the real value.
Please allow me not to comment on mysql behaviour...
> 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?
NEXTVAL('<table>_<field>_seq') should work.
--
Alessio F. Bragadini alessio@albourne.com
APL Financial Services http://www.sevenseas.org/~alessio
Nicosia, Cyprus phone: +357-2-750652
"It is more complicated than you think"
-- The Eighth Networking Truth from RFC 1925
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: alessio@albourne.com, emils@mail.usis.bkc.lv
Subject: Re: [SQL] INSERT w/o variable names for a SERIAL type?
In-Reply-To: <38B69C52.11EEF672@albourne.com>
References: <200002251428.QAA06635@www.usis.bkc.lv> <38B69C52.11EEF672@albourne.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox