| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| How to use a LIMIT claue with OQLOverview Intended Audience Prerequisites Steps Compose an OQL statement to obtain all ProductGroup instances Add LIMIT clause to OQL statement Add OFFSET clause to OQL statement Limitations Tips References Overview
Intended AudienceAnyone who wants to execute an OQL statement and limit the result size. The example given describes the addition of LIMIT/OFFEST clauses to an existing OQL statement. PrerequisitesYou should have a valid class mapping for two Java classes Product and ProductGroup, similar to the following one:
The following fragment shows the Java class declaration for the ProductGroup class:
StepsHere is how to proceed. Compose an OQL statement to obtain all ProductGroup instancesThe following code fragment shows an OQL query to select the all ProductGroup instances.
Add LIMIT clause to OQL statementThe following code fragment shows the same OQL query as above, to this time the LIMIT keyword is added to select the first 10 ProductGroup instances only.
Add OFFSET clause to OQL statementBelow is the same OQL query again, restricting the number of ProductGroup instances returned to 10, though this time it is specified that the ProductGroup instances 101 to 110 should be returned.
LimitationsThe following RDBMS fully/partially support LIMIT/OFFSET clauses.
1) Caster has full support for LIMIT/OFFSET clauses for Oracle Releases 8.1.6 and later. 2) For the LIMIT/OFFSET clauses to work properly the OQL query is required to include an ORDER BY clause. Tips
References
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||