You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ch...@apache.org on 2011/08/22 15:15:52 UTC

svn commit: r1160256 - /db/derby/docs/branches/10.8/src/ref/rrefsqljoffsetfetch.dita

Author: chaase3
Date: Mon Aug 22 13:15:52 2011
New Revision: 1160256

URL: http://svn.apache.org/viewvc?rev=1160256&view=rev
Log:
DERBY-5385  Improve documentation for OFFSET/FETCH NEXT

Merged DERBY-5385.diff to 10.8 docs branch from trunk revision 1160250.

Modified:
    db/derby/docs/branches/10.8/src/ref/rrefsqljoffsetfetch.dita

Modified: db/derby/docs/branches/10.8/src/ref/rrefsqljoffsetfetch.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/branches/10.8/src/ref/rrefsqljoffsetfetch.dita?rev=1160256&r1=1160255&r2=1160256&view=diff
==============================================================================
--- db/derby/docs/branches/10.8/src/ref/rrefsqljoffsetfetch.dita (original)
+++ db/derby/docs/branches/10.8/src/ref/rrefsqljoffsetfetch.dita Mon Aug 22 13:15:52 2011
@@ -57,15 +57,16 @@ ROW is synonymous with ROWS and FIRST is
 </p>
 
 <p>
-For the <i>result offset clause</i> the integer literal (or dynamic
-parameter) must be equal to
+For the <i>result offset clause</i>, the value of the integer literal (or the
+dynamic parameter <codeph>?</codeph>) must be equal to
 0 (default if the clause is not given), or positive. If it is larger
 than the number of rows in the underlying result set, no rows are
 returned.
 </p>
 
 <p>
-For the <i>fetch first clause</i>, the literal (or dynamic parameter) must be 1 or
+For the <i>fetch first clause</i>, the value of the literal (or the dynamic
+parameter <codeph>?</codeph>) must be 1 or
 higher. The literal can be omitted, in which case it defaults to 1. If
 the clause is omitted entirely, all rows (or those rows remaining if
 a <i>result offset clause</i> is also given) will be returned.
@@ -84,7 +85,16 @@ SELECT * FROM T ORDER BY I OFFSET 10 ROW
 --   returned
 SELECT * FROM T OFFSET 100 ROWS
 
-JDBC:
+-- Use of ORDER BY and FETCH FIRST in a subquery
+SELECT DISTINCT A.ORIG_AIRPORT, B.FLIGHT_ID FROM 
+   (SELECT FLIGHT_ID, ORIG_AIRPORT 
+       FROM FLIGHTS 
+       ORDER BY ORIG_AIRPORT DESC 
+       FETCH FIRST 40 ROWS ONLY) 
+    AS A, FLIGHTAVAILABILITY AS B 
+   WHERE A.FLIGHT_ID = B.FLIGHT_ID
+
+JDBC (using a dynamic parameter):
 PreparedStatement p = 
     con.prepareStatement("SELECT * FROM T ORDER BY I OFFSET ? ROWS");
 p.setInt(1, 100);