Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5CF62475D01 for ; Tue, 3 Dec 2002 07:56:23 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id B14BF475CC4 for ; Tue, 3 Dec 2002 07:56:19 -0500 (EST) Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.11.6/8.11.6) with ESMTP id gB3D5Nu07047; Tue, 3 Dec 2002 15:05:23 +0200 Date: Tue, 3 Dec 2002 15:05:23 +0200 (EET) From: Achilleus Mantzios To: Pedro Igor Cc: pgsql-sql@postgresql.org Subject: Re: SQL QUERY In-Reply-To: <001001c29ac9$8f8de3e0$0b00010a@aip.com.br> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/26 X-Sequence-Number: 10614 On Tue, 3 Dec 2002, Pedro Igor wrote: > I have the following function: > CREATE FUNCTION public.auto_incremento() RETURNS trigger AS ' > begin > new.id = (select (max(id) + 1) from teste); > return new; > end;' LANGUAGE 'plpgsql' > > I created a trigger that uses this function, but i want to the function be usefull for all tables and not only to tbale teste. > > Someone know how ??? Take a look at sequences. (In Addition, they are autimatically created when a column is of type 'SERIAL'). > > > > Pedro Igor > > > > ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr