Обсуждение: How To Return a Row or Result Set

Поиск
Список
Период
Сортировка

How To Return a Row or Result Set

От
Ketema Harris
Дата:
I believe i figured it out...

CREATE OR REPLACE FUNCTION "public"."recruiting_login" (_username
varchar, _password varchar) RETURNS setof credentials AS
'
    declare
        user_creds credentials;
    begin
        if _password = (select "password" from recruiting_users where
username = _username) then
            select into user_creds user_id, "admin" from
recruiting_users where username = _username;
        else
            select into user_creds 0, false from recruiting_users;
        end if;
        return next user_creds;
    end;
'
LANGUAGE 'plpgsql'

is the best and correct way to Return a Row or Result Set?