how to return parts of records from a function

Поиск
Список
Период
Сортировка
От A B
Тема how to return parts of records from a function
Дата
Msg-id dbbf25900805140823w5413a2c0mcc577552564ae42b@mail.gmail.com
обсуждение исходный текст
Ответы Re: how to return parts of records from a function  (Craig Ringer <craig@postnewspapers.com.au>)
Список pgsql-general
Hello.
I think I need som help on this function I write in plpgsql
I want to return
CREATE OR REPLACE FUNCTION gList(tid_ TIMESTAMP) RETURNS AS $$
DECLARE
    rec RECORD;
BEGIN
    FOR rec IN SELECT DISTINCT custid,action,nr FROM ...
        IF rec.action = ...
        END IF;
        RETURN NEXT  ???????????????
    END LOOP;
    RETURN;
END;
$$ LANGUAGE plpgsql;

I want to replace the ????????? with  something that will contain both
rec.nr  and rec.action. What should that looklike?  rec.nr ,
rec.action  ?
And what should I write after RETURNS ....  in the first line? RECORD?

Oh, now that I write this I understand that I could replace the RETURN
NEXT in the loop with a single RETURN QUERY at the end... I don't know
if that will be good, but I still would like to know how to return the
separate fields from the rec  record.

В списке pgsql-general по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: ranked subqueries vs distinct question
Следующее
От: David McNett
Дата:
Сообщение: Re: ranked subqueries vs distinct question