X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 51A09DB023 for ; Thu, 27 Oct 2005 01:38:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47817-08 for ; Thu, 27 Oct 2005 04:38:45 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 60227DB01D for ; Thu, 27 Oct 2005 01:38:45 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j9R4c454005131 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 26 Oct 2005 22:38:07 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id j9R4c42F061168; Wed, 26 Oct 2005 22:38:04 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id j9R4c3LW061167; Wed, 26 Oct 2005 22:38:03 -0600 (MDT) (envelope-from mfuhr) Date: Wed, 26 Oct 2005 22:38:03 -0600 From: Michael Fuhr To: Bob Pawley Cc: Terry Lee Tucker , Postgre General Subject: Re: Error Message Message-ID: <20051027043803.GA61100@winnie.fuhr.org> References: <03a301c5da6e$a20b6280$ac1d4318@OWNER> <11706.1130361821@sss.pgh.pa.us> <041401c5da84$7429ec90$ac1d4318@OWNER> <200510261945.19824.terry@esc1.com> <20051027010006.GA59813@winnie.fuhr.org> <001601c5daa0$d2e717f0$ac1d4318@OWNER> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001601c5daa0$d2e717f0$ac1d4318@OWNER> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/1690 X-Sequence-Number: 85918 On Wed, Oct 26, 2005 at 07:47:51PM -0700, Bob Pawley wrote: > I have a base table called "process". Each row of this table is anchored by > a serial column labeled "fluid_id". What do you mean by "anchored by"? Is fluid_id the primary key for process? Or is fluid_id a foreign key reference to some other table? Or do you mean something else? > After data has been entered into a row in "process", I want to trigger a > row in another table labeled "specification" also with a column labeled > "fluid_id". I would like this number from "process" entered into > "specification" as an integer. By "trigger a row" do you mean that you want the trigger on process to insert a new row into specification? Is the following example close to what you're looking for? CREATE TABLE process (fluid_id integer PRIMARY KEY); CREATE TABLE specification (fluid_id integer NOT NULL); CREATE FUNCTION base() RETURNS trigger AS $$ BEGIN INSERT INTO specification (fluid_id) VALUES (NEW.fluid_id); RETURN NULL; -- ignored in AFTER triggers END; $$ LANGUAGE plpgsql; CREATE TRIGGER trig1 AFTER INSERT ON process FOR EACH ROW EXECUTE PROCEDURE base(); INSERT INTO process (fluid_id) VALUES (123); INSERT INTO process (fluid_id) VALUES (456); SELECT * FROM process; fluid_id ---------- 123 456 (2 rows) SELECT * FROM specification; fluid_id ---------- 123 456 (2 rows) -- Michael Fuhr