Re: new and old as parameter in a function - Mailing list pgsql-sql

From Tom Lane
Subject Re: new and old as parameter in a function
Date
Msg-id 26365.1083847897@sss.pgh.pa.us
Whole thread Raw
In response to new and old as parameter in a function  ("Riccardo G. Facchini" <abief_ag_-postgresql@yahoo.com>)
List pgsql-sql
"Riccardo G. Facchini" <abief_ag_-postgresql@yahoo.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


pgsql-sql by date:

Previous
From: "Riccardo G. Facchini"
Date:
Subject: new and old as parameter in a function
Next
From: Andrew Sullivan
Date:
Subject: Re: not really SQL but I need info on BLOBs