X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3E1FB47592C for ; Fri, 7 Feb 2003 03:28:52 -0500 (EST) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by postgresql.org (Postfix) with SMTP id 04F824758FE for ; Fri, 7 Feb 2003 03:28:51 -0500 (EST) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Fri Feb 07 09:28:50 2003 +0100 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id JAA15425; Fri, 7 Feb 2003 09:28:50 +0100 (MET) Message-ID: <3E436E41.ABA852F5@rodos.fzk.de> Date: Fri, 07 Feb 2003 09:28:50 +0100 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Cc: mweaver@corpusglobe.com Subject: Re: "function has no parameter $1" - help. Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/141 X-Sequence-Number: 11539 > > I'm trying to create a trigger to enforce a constraint onto two possible > foreign tables > my function is defined as: > > <-- snip --> > CREATE OR REPLACE FUNCTION > sp_check_tranitem_productid(tbl_tranitem.fld_tranitem_id%TYPE, > tbl_tranitem.fld_tranitem_type%TYPE) RETURNS > OPAQUE AS ' > DECLARE > -------[Parameters]------- > pl_product_id ALIAS FOR $1; > pl_product_type ALIAS FOR $2; > <-- snip --> > > but when I call the function I get the error: > > function has no parameter $1 > > What is going wrong? > > (I am using PostgreSQL 7.3.1) > The documentation says about trigger procedures: PL/pgSQL can be used to define trigger procedures. A trigger procedure is created with the CREATE FUNCTION command as a function with no arguments and a return type of OPAQUE. Note that the function must be declared with no arguments even if it expects to receive arguments specified in CREATE TRIGGER --- trigger arguments are passed via TG_ARGV, as described below. Refer to that chapter for an example. Regards, Christoph