Creating SQL functions

From: Erich <hh(at)cyberpass(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Creating SQL functions
Date: 2000-09-12 23:55:12
Message-ID: 200009122355.QAA27944@cyberpass.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-general by date

  From Date Subject
Next Message Oleg Bartunov 2000-09-13 03:07:00 Re: [SQL] Weighted Searching
Previous Message Erich 2000-09-12 22:48:05 Contract for adding replication support to Postgres