Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6C0894762D3 for ; Wed, 13 Nov 2002 14:42:30 -0500 (EST) Received: from wolff.to (unknown [66.93.197.35]) by postgresql.org (Postfix) with SMTP id 963B64762C6 for ; Wed, 13 Nov 2002 14:42:29 -0500 (EST) Received: (qmail 10914 invoked by uid 500); 13 Nov 2002 19:52:19 -0000 Date: Wed, 13 Nov 2002 13:52:19 -0600 From: Bruno Wolff III To: Luis Sousa Cc: Robert Treat , Josh Berkus , pgsql-sql Subject: Re: Permission on insert rules Message-ID: <20021113195219.GA10480@wolff.to> Mail-Followup-To: Luis Sousa , Robert Treat , Josh Berkus , pgsql-sql References: <1037137215.27220.64.camel@camel> <3DD22D03.4090505@ualg.pt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3DD22D03.4090505@ualg.pt> User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/210 X-Sequence-Number: 10352 On Wed, Nov 13, 2002 at 10:44:19 +0000, Luis Sousa wrote: > > I have a table, whose primary key is a serial, that is connected to a > few tables. In this view, I want to insert data, in the main table, and > also in the "child" tables. My idea was to create a rule, that first > inserts in the parent table, and some functions, that will select the > parent table returning the id created, and will insert some data on > child table (I'm open for sugestions to do this !!!). I don't know > exactly how this works if more than one user at the same time !!!! You can use currval to retrieve the last value assigned to a specified sequence in the current session. This is transaction safe.