The biggest issue I have right now is deciding the syntax. SQL 2008
specifies the following syntax for the limit clause that appears after
the order by clause.
Option A (ANSI SQL)
[ OFFSET integer-literal {ROW | ROWS} ]
[ FETCH { FIRST | NEXT } [integer-literal] {ROW | ROWS} ONLY ]
This is the standard, but quite verbose. Specifying first, next, row,
rows, or only has absolutely no effect, but is required by the
standard.
Option B (PostgreSQL, MySQL, etc.)
[LIMIT integer]
[OFFSET integer]
I'm not even going to propose using something like row_number as a hql syntax.
What are people's thoughts on this?
Patrick Earl
Richard
Sent from my HTC phone
----- Ursprüngliche Nachricht -----
Von: Richard Birkby <rbi...@gmail.com>
Gesendet: Sonntag, 6. Februar 2011 08:32
An: nhibernate-...@googlegroups.com <nhibernate-...@googlegroups.com>
Betreff: Re: [nhibernate-development] Limit and Offset support in HQL
1. I can't think of a single RDBMS that actually implements the ANSI
standard (SQL Server team are you listening?);
2. The OFFSET x LIMIT y is the most readable (bay far), and is closest to
our internal implementation terminology;
3. I can't think of a single advantage to the more verbose option and it
looks like more work.
-----Original Message-----
From: Wenig, Stefan
Sent: Sunday, February 06, 2011 9:47 AM
To: nhibernate-...@googlegroups.com
Subject: AW: Re: [nhibernate-development] Limit and Offset support in HQL
Those 2 don't work for subqueries, that's why we need it in the grammar
AKAIR.
Sent from my HTC phone
----- Urspr�ngliche Nachricht -----
IBM DB2, Sybase SQL Anywhere, PostgreSQL, EffiProz and HSQLDB version 2.0
SKIP x TAKE y
OFFSET x LIMIT y
Seems like Fabio and Diego prefer the first two. I'm also liking the
skip and take a bit more at this point, since it's more descriptive,
despite being less standard from a SQL perspective. Other's thoughts?
Patrick Earl
I vote for the skip and take version... they all need to be translated anyway why not pick something that is easy to remember
Option i: SKIPPING x TAKING y SELECT ... FROM ... WHERE ... ORDER BY ...
Option ii: SKIP x TAKE y SELECT ... FROM ... WHERE ... ORDER BY ...
Option iii: SELECT ... FROM ... WHERE ... ORDER BY ... SKIP x TAKE y
For the first, people would need to get the spelling right on
skipping, unless we just supported both versions (skipping and
skiping).
Patrick
Juts to avoid any complaints about completeness,
Option iv: SELECT ... FROM ... WHERE ... ORDER BY ... SKIPPING x TAKING y
Patrick
+1 for option ii -- simpler and less ambiguous.
Btw, while on the subject of extensing HQL, should this effort be
coordinated with or at least communicated to the Hibernate team?
http://en.wikipedia.org/wiki/Select_(SQL)#FETCH_FIRST_clause
So, to recap:
Option i: SKIPPING x TAKING y SELECT ... FROM ... WHERE ... ORDER BY ...
Option ii: SKIP x TAKE y SELECT ... FROM ... WHERE ... ORDER BY ...
Option iii: SELECT ... FROM ... WHERE ... ORDER BY ... SKIP x TAKE y
Option iv: SELECT ... FROM ... WHERE ... ORDER BY ... SKIPPING x TAKING y
Option v: SELECT FIRST x SKIP y ... FROM ... WHERE ... ORDER BY ...
Option vi: SELECT TOP x SKIP y ... FROM ... WHERE ... ORDER BY ...
Patrick Earl
Both of these seem confusing to me. Take the first 100 elements and
then skip 30, i.e. returning row 31 up to 100, that is return 70 rows?
Option iii seems natural to me - with skip/take close to order by,
since order by is usually vital in this situtation.
As for grammar.... SQL sounds like commands, not a narrative. We order
the database to select some data from rows where this and that, we
also order it to skip some rows and take others. In contract, we do
not tell a story, where we describe how the db is selecting, ordering,
and skipping. So the grammar in option iii seems correct to me.
/Oskar
As for intuitive... Is is really intuitive to mash the number of rows
to return together with the column specification? For me it feels more
natural to keep it close to ORDER BY... but then I learned SQL using
Postgresql. :)
2011/2/6 Michael Teper <mte...@gmail.com>:
/Oskar
2011/2/6 Fabio Maulo <fabio...@gmail.com>: