From: Dani Oderbolz <oderbolz@ecologic.de>
To: pgsql-sql@postgresql.org
Subject: Change the behaviour of the SERIAL "Type"
Date: Thu, 26 Jun 2003 14:31:34 +0200
Message-ID: <3EFAE7A6.9070904@ecologic.de> (raw)
Hi all,
I am struggling hard with a badly written piece of code.
It has such statements all over the place:
INSERT INTO TABLE A (NULL, Value1, Value2...).
It was written for MySQL, which can take NULL and then assign an
auto_increment.
However, in PostgreSQL I am getting problems, because it would not let
me insert NULL
into a NOT NULL column (which is perfectly sensible from my point of view).
But as the author has also left out the column list in the insert, its
really tedious to change
the code.
Therefore I was thinking whether it was possible to change the meaning
of SERIAL in my DB,
so that it would actually generate a Trigger on the table, which would
then take care
of the SERIAL value. (Getting nextval from the sequence and write all
into the table)
This way, there would be no possibility to circumvent the Value which
comes from the Sequence.
To me, this would make more sense anyway than just setting the DEFAULT
of a coulmn
(and as far as I understood, this is what SERIAL does, right?)
Is there a way to change SERIAL this way?
Cheers, Dani
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: oderbolz@ecologic.de
Subject: Re: Change the behaviour of the SERIAL "Type"
In-Reply-To: <3EFAE7A6.9070904@ecologic.de>
* 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