Re: Documentation regarding %ROWTYPE in PL/PgSQL

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew McMillan <andrew@catalyst.net.nz>
Cc: pgsql-bugs@postgresql.org
Date: 2002-05-28T13:41:02Z
Lists: pgsql-bugs
Andrew McMillan <andrew@catalyst.net.nz> writes:
> ... I can't supply either %ROWTYPE or %TYPE within the parameter
> definition without an error either.

Looks like I was mistaken: table.field%type works, but table%type
does not:

test72=# create table foo (f1 int, f2 text);
CREATE
test72=# create function foo(foo.f1%type) returns int as 'select $1'
test72-# language sql;
NOTICE:  foo.f1%TYPE converted to int4
CREATE
test72=# create function foo(foo%type) returns text as 'select $1.f2'
test72-# language sql;
ERROR:  parser: parse error at or near "%"

So you must do it as:

test72=# create function foo(foo) returns text as 'select $1.f2'
test72-# language sql;
CREATE

> Is it a good idea to provide an example (such as the above), or should I
> just try and describe the behaviour?

Examples are generally good things ...

			regards, tom lane