Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group