I have Postgresql 8.1 and I have attempted to follow the docs to do
the following:
I created a composite type:
create type credentials as (user_id int, admin bool);
it showed up fine:
Composite type "public.credentials"
Column | Type
---------+---------
user_id | integer
admin | boolean
I then attempted to create a function that would return this type as a
resultl set:
CREATE OR REPLACE FUNCTION "public"."recruiting_login" (_username
varchar, _password varchar) RETURNS setof credentials AS
'
begin
if _password = (select password from recruiting_users where
username = _username) then
select user_id, "admin" from recruiting_users where
username = _username;
else
select 0, false from recruiting_users;
end if;
end;
'
LANGUAGE 'plpgsql'
but when i execute this function i receive this error:
ERROR: SELECT query has no destination for result data
HINT: If you want to discard the results, use PERFORM instead.
CONTEXT: PL/pgSQL function "recruiting_login" line 3 at SQL statement
How do I accomplish this correctly?
Thanks.