X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8BEF7D1B4B3 for ; Mon, 26 Apr 2004 04:47:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 16873-02 for ; Mon, 26 Apr 2004 04:47:15 -0300 (ADT) Received: from web13906.mail.yahoo.com (web13906.mail.yahoo.com [216.136.175.69]) by svr1.postgresql.org (Postfix) with SMTP id CEF81D1B498 for ; Mon, 26 Apr 2004 04:47:12 -0300 (ADT) Message-ID: <20040426074713.32544.qmail@web13906.mail.yahoo.com> Received: from [80.67.100.162] by web13906.mail.yahoo.com via HTTP; Mon, 26 Apr 2004 00:47:13 PDT Date: Mon, 26 Apr 2004 00:47:13 -0700 (PDT) From: "Riccardo G. Facchini" Subject: Re: Trigger calling a function HELP ME! (2) To: pgsql-sql@postgresql.org In-Reply-To: <200404221219.12694.dev@archonet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/271 X-Sequence-Number: 17646 --- Richard Huxton wrote: > On Wednesday 21 April 2004 16:16, abief_ag_-postgresql(AT)yahoo.com > wrote: > > > CREATE OR REPLACE FUNCTION public.imp_test_to_out_test(imp_test) > > RETURNS imp_test AS > > 'begin > > return $1; > > end;' > > LANGUAGE 'plpgsql' STABLE; > > > > CREATE OR REPLACE FUNCTION public.imp_test_trigger() > > RETURNS trigger AS > > 'begin > > return imp_test_to_out_test(new); > > end;' > > LANGUAGE 'plpgsql' STABLE; > > This is your problem. NEW is a special variable, and I don't think > you can > pass it into another function (other than as NEW.col1, NEW.col2, > NEW.col3 > etc). > > You can however use TG_NAME or TG_RELNAME to see what trigger/table > called > you. I find that's helpful. > -- > Richard Huxton > Archonet Ltd > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org One other issue, as I understand it, NEW (and OLD) is a variable of type record, so you should be able to pass it to a function and get it as a return value, but it seems that there is a bug reported for version 7.2.1 that inhibits the use of record as type to be passed to a function. any suggestion? ===== Riccardo G. Facchini