Re: How to implement oracle like rownum(function or seudocolumn)

Поиск
Список
Период
Сортировка
От Jonah H. Harris
Тема Re: How to implement oracle like rownum(function or seudocolumn)
Дата
Msg-id 36e682920604081120q768ab245je099cdf32c9a332f@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to implement oracle like rownum(function or seudocolumn)  (Jan Wieck <JanWieck@Yahoo.com>)
Список pgsql-hackers
On 4/8/06, Jan Wieck <JanWieck@yahoo.com> wrote:
> Someone correct me if I'm wrong, but I was allways under the impression
> that Oracle's ROWNUM is a thing attached to a row in the final result
> set, whatever (possibly random) order that happens to have. Now a) this
> is something that IMHO belongs into the client or stored procedure code,
> b) if I am right, the code below will break as soon as an ORDER BY is
> added to the query and most importantly c) if a) cannot do the job, it
> indicates that the database schema or business process definition lacks
> some key/referential definition and is in need of a fix.

Yes, a rownum is assigned at fetch time.

An example is the following PostgreSQL query:

SELECT id FROM sometable ORDER BY id LIMIT 5;

In Oracle-land is written as:

SELECT id FROM (SELECT id FROM sometable ORDER BY id) WHERE rownum <= 5;

> My humble guess is that c) is also the reason why the ANSI didn't find a
> ROWNUM desirable.

I believe this is a good assumption.


--
Jonah H. Harris, Database Internals Architect
EnterpriseDB Corporation
732.331.1324


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

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: How to implement oracle like rownum(function or seudocolumn)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: ERROR: record type has not been registered on CVS head