Re: row numbering
От | josue |
---|---|
Тема | Re: row numbering |
Дата | |
Msg-id | 422081EF.7080105@lamundial.hn обсуждение исходный текст |
Ответ на | Re: row numbering (Jeff Davis <jdavis-pgsql@empires.org>) |
Список | pgsql-general |
Jeff Davis wrote: > Here's an example using plperl and global variables. The variables are > local to a session so you don't have to worry about the counters > interfering. If you need two counters in a session, just execute > reset_counter(). > > CREATE OR REPLACE FUNCTION reset_counter() RETURNS INT AS $$ > $_SHARED{counter} = 0; > return 0; > $$ LANGAUGE plperl; > > CREATE OR REPLACE FUNCTION counter() RETURNS INT AS $$ > return $_SHARED{counter}++; > $$ LANGUAGE plperl; > > Now, you can execute the queries just like you want: > select counter(),a,b from foo; > > There are a couple trivial issues, like you can start from 1 instead of > 0 if you want. Thanks, all the ideas you and the other members gave me have been very helpfully -- Sinceramente, Josué Maldonado. ... "Ser fiel supone engañar a tu pareja en el momento justo"
В списке pgsql-general по дате отправления: