Skip site navigation (1) Skip section navigation (2)

INSERT w/o variable names for a SERIAL type?

From: "Emils Klotins" <emils(at)mail(dot)usis(dot)bkc(dot)lv>
To: <pgsql-sql(at)postgreSQL(dot)org>
Subject: INSERT w/o variable names for a SERIAL type?
Date: 2000-02-25 13:59:40
Message-ID: 200002251428.QAA06635@www.usis.bkc.lv (view raw or flat)
Thread:
Lists: pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello.


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(?).

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

and currently stumbled upon mysql version of inserting the 
autoincrement value: NULL
ie.
CREATE TABLE mytable (id SERIAL PRIMARY KEY, textfield 
text);
the mysql variant for inserting a row would be:

INSERT INTO mytable VALUES (NULL, 'textvalue');
and NULL would get translated into the real value.

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?

Emils


-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.2 -- QDPGP 2.61a
Comment: http://community.wow.net/grt/qdpgp.html

iQA/AwUBOLZuld0sxa1MAPWHEQJtVACg3Nsd7YiH3q2aXkIMSM/mjaLD3fgAn0bu
S4NHXOsVsS26nntkkInqxBJw
=HodA
-----END PGP SIGNATURE-----

Responses

pgsql-sql by date

Next:From: Alessio BragadiniDate: 2000-02-25 15:14:26
Subject: Re: [SQL] INSERT w/o variable names for a SERIAL type?
Previous:From: NeduDate: 2000-02-25 13:54:13
Subject: Problem - Postgres Running continously

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group