pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Wieck <janwieck@Yahoo.com>
To: Cedar Cox <cedarc@visionforisrael.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: passing values to a function
Date: Mon, 19 Feb 2001 14:32:09 -0500 (EST)
Message-ID: <200102191932.OAA01894@jupiter.jw.home> (raw)
In-Reply-To: <Pine.LNX.4.21.0102181655080.22616-100000@nanu.visionforisrael.com>

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




view thread (4+ messages)  latest in thread

Message-ID: <200102191932.OAA01894@jupiter.jw.home>
Permalink:  ../200102191932.OAA01894@jupiter.jw.home/
Also on:    postgresql.org/message-id/200102191932.OAA01894@jupiter.jw.home

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: janwieck@Yahoo.com, cedarc@visionforisrael.com
  Subject: Re: passing values to a function
  In-Reply-To: <200102191932.OAA01894@jupiter.jw.home>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox