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