Received: from sapphire.albourne.com (sapphire.albourne.com [195.212.241.227]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA16521 for ; Fri, 25 Feb 2000 10:14:37 -0500 (EST) (envelope-from alessio@albourne.com) Received: from albourne.com (akamas.albourne.com [195.212.241.254]) by sapphire.albourne.com (8.9.3/8.9.3/Albourne/CYS/1.8/MAPS) with ESMTP id RAA08924; Fri, 25 Feb 2000 17:14:27 +0200 (EET) Sender: alessio@albourne.com Message-ID: <38B69C52.11EEF672@albourne.com> Date: Fri, 25 Feb 2000 17:14:26 +0200 From: Alessio Bragadini Organization: APL Financial Services (Overseas) Ltd. X-Mailer: Mozilla 4.7 [en] (X11; I; OSF1 V4.0 alpha) X-Accept-Language: it, en, sv MIME-Version: 1.0 To: Emils Klotins CC: pgsql-sql@postgreSQL.org Subject: Re: [SQL] INSERT w/o variable names for a SERIAL type? References: <200002251428.QAA06635@www.usis.bkc.lv> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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('__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('
__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