Re: Documentation regarding %ROWTYPE in PL/PgSQL

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Documentation regarding %ROWTYPE in PL/PgSQL
Дата
Msg-id 2642.1022593262@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Documentation regarding %ROWTYPE in PL/PgSQL  (Andrew McMillan <andrew@catalyst.net.nz>)
Ответы Re: Documentation regarding %ROWTYPE in PL/PgSQL  (Andrew McMillan <andrew@catalyst.net.nz>)
Список 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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Karel Zak
Дата:
Сообщение: Re: Bug #680: NOCREATETABLE
Следующее
От: Christian Zagrodnick
Дата:
Сообщение: plpgsql function behaves strange