Re: new and old as parameter in a function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Riccardo G(dot) Facchini" <abief_ag_-postgresql(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: new and old as parameter in a function
Date: 2004-05-06 12:51:37
Message-ID: 26365.1083847897@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Riccardo G. Facchini" <abief_ag_-postgresql(at)yahoo(dot)com> writes:
> By Reading the documentation, I understand that I can write a PLPGSQL
> function that receives a parameter of type RECORD,

You misread it --- that's not presently supported.

regression=# create function foo(record) returns int as '
regression'# begin
regression'# return $1.f1;
regression'# end' language plpgsql;
ERROR: plpgsql functions cannot take type record

However you can make a plpgsql function that accepts a parameter of a
specific (named) rowtype:

regression=# create table fooey(f1 int, f2 text);
CREATE TABLE
regression=# create function foo(fooey) returns int as '
regression'# begin
regression'# return $1.f1;
regression'# end' language plpgsql;
CREATE FUNCTION

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2004-05-06 12:55:06 Re: not really SQL but I need info on BLOBs
Previous Message Riccardo G. Facchini 2004-05-06 12:24:33 new and old as parameter in a function