How To Return a Row or Result Set
От | Ketema Harris |
---|---|
Тема | How To Return a Row or Result Set |
Дата | |
Msg-id | 983b67500602010800g32e5bff5nab5ab8ac06150011@mail.gmail.com обсуждение исходный текст |
Список | pgsql-novice |
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.
В списке pgsql-novice по дате отправления: