Обсуждение: Qestion about CREATE FUNCTION

Поиск
Список
Период
Сортировка

Qestion about CREATE FUNCTION

От
"Cornelia Boenigk"
Дата:
Hi all

I defined the following function:

CREATE FUNCTION ka(member)
RETURNS member AS
'UPDATE member SET m_email = ''unbekannt'' WHERE m_email = NULL:
SELECT * FROM member;'
LANGUAGE 'sql';

If I call
SELECT ka(member) FROM member;
      ka
-------------
 12257440
.....

I get this number as many times as the table consists rows (no matter
weather they were updated or not). Could anybody tell me what kind of
result this is? What does this number mean?

If I use the notation with $1 like in the Programmers Guide in chapter
13.1.3 I get a parsing error. (??)

Could anybody explain this behaviour?

Thanks and greetings
Conni




Re: Qestion about CREATE FUNCTION

От
Tom Lane
Дата:
"Cornelia Boenigk" <poppcorn@cornelia-boenigk.de> writes:
> Could anybody explain this behaviour?

See
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/xfunc-sql.html
which says in part:

    In the present release of PostgreSQL there are some unpleasant
    restrictions on how functions returning composite types can be
    used. Briefly, when calling a function that returns a row, we cannot
    retrieve the entire row. We must either project a single attribute out
    of the row or pass the entire row into another function. (Trying to
    display the entire row value will yield a meaningless number.)

            regards, tom lane