Creating SQL functions

Поиск
Список
Период
Сортировка
От Erich
Тема Creating SQL functions
Дата
Msg-id 200009122355.QAA27944@cyberpass.net
обсуждение исходный текст
Список pgsql-general
I'm trying to create a function like this:

CREATE FUNCTION usercolor (INT)
    RETURNS INT
    AS 'SELECT color
        FROM users
        WHERE number = $1
        ORDER BY time
        LIMIT 1'
        LANGUAGE 'sql';

and it doesn't work.  It gives me an error that the return type is
INT, but the SELECT statement might return more than one value.  Well,
it can only return one value because of the LIMIT 1.  What's the best
way to do this kind of thing?  Is this a bug in Postgres?

Thanks,

e

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

Предыдущее
От: Erich
Дата:
Сообщение: Contract for adding replication support to Postgres
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: [SQL] Weighted Searching