Received: from smtp017.mail.yahoo.com (smtp017.mail.yahoo.com [216.136.174.114]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f1JKGox93325 for ; Mon, 19 Feb 2001 15:16:50 -0500 (EST) (envelope-from janwieck@yahoo.com) Received: from a5bfd.pppool.de (HELO jupiter.jw.home) (213.6.91.253) by smtp.mail.vip.sc5.yahoo.com with SMTP; 19 Feb 2001 20:16:48 -0000 X-Apparently-From: Received: (from janwieck@localhost) by jupiter.jw.home (8.9.3/8.9.3) id OAA01894; Mon, 19 Feb 2001 14:32:09 -0500 From: Jan Wieck Message-Id: <200102191932.OAA01894@jupiter.jw.home> Subject: Re: passing values to a function In-Reply-To: from Cedar Cox at "Feb 18, 2001 05:03:23 pm" To: Cedar Cox Date: Mon, 19 Feb 2001 14:32:09 -0500 (EST) CC: pgsql-interfaces@postgresql.org X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200102/122 X-Sequence-Number: 1079 Cedar Cox wrote: > > Why does this not work? Am I doing something wrong? > > CREATE FUNCTION uutest(text) RETURNS bool AS ' > declare > varop alias for $1; > begin > raise notice '' varop is '',varop; raise notice '' varop is %'', varop; > return false; > end; > ' LANGUAGE 'plpgsql'; > [...] > > One other question.. Is there an easy way to pass an entire record to a > function (eg, the 'new' record)? Presently I am passing all 12 fields as > separate parameters. Yes and no. Yes, PL/pgSQL functions can receive tuples as arguments. The only oddity is that they *must* get aliased for access of attributes. Your function would look like: CREATE FUNCTION myfunc (mytable) RETURNS text AS ' DECLARE row ALIAS FOR %1; BEGIN return row.key || '' equals '' row.value; END;' LANGUAGE 'plpgsql'; But unfortunately (and there's no really good reason why) no, a PL/pgSQL function having some row somehow cannot call another function handing that row over as a tuple argument. Something to work on for 7.2. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com