order by in for loop in plpgsql does not work

Поиск
Список
Период
Сортировка
От Jean-Luc Lachance
Тема order by in for loop in plpgsql does not work
Дата
Msg-id 3DE3DB32.8138C2C8@nsd.ca
обсуждение исходный текст
Ответ на Re: Compatibility of future releases  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-general
Any idea why when I call this function the record are not processed in
the order requested?

JLL

P.S.

It would be nice if the syntax would allow me to write something like >>
cur.seqno = seq
and have the underlying record updated.



declare

cur record;
seq int;
exchangeno text;
routeno text;

begin

exchangeno := '';
routeno := '';

for cur in
    select oid, * from r order by exchangeno, routeno, street,
municipality, parity desc, fromno for update
loop
    if cur.exchangeno != exchangeno or cur.routeno != routeno
    then
        seq := 1;
        exchangeno := cur.exchangeno;
        routeno := cur.routeno;
    end if;
    update r set seqno = seq, route = routeno || trim( lpad( seq, 4, '0'))
where oid = cur.oid;
    seq := seq + 1;
end loop;

return 0;
end;

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Compatibility of future releases
Следующее
От: Jean-Luc Lachance
Дата:
Сообщение: Re: order by in for loop in plpgsql does not work