X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 76C3430FB56 for ; Thu, 26 Jun 2003 12:31:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 42600-10 for ; Thu, 26 Jun 2003 09:31:38 -0300 (ADT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by svr1.postgresql.org (Postfix) with ESMTP id 8481D30FB11 for ; Thu, 26 Jun 2003 09:31:37 -0300 (ADT) Received: from [212.227.126.206] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 19VVub-0002lL-00 for pgsql-sql@postgresql.org; Thu, 26 Jun 2003 14:31:37 +0200 Received: from [217.230.202.171] (helo=ecologic.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 19VVub-0005IY-00 for pgsql-sql@postgresql.org; Thu, 26 Jun 2003 14:31:37 +0200 Message-ID: <3EFAE7A6.9070904@ecologic.de> Date: Thu, 26 Jun 2003 14:31:34 +0200 From: Dani Oderbolz User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3.1) Gecko/20030425 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Change the behaviour of the SERIAL "Type" Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200306/294 X-Sequence-Number: 14052 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