Query failing for next 50 records

2145
4
09-06-2012 11:11 AM
NaveenKatta
New Contributor III
Hi All,

I am querying the rest using query.where= "rownum >= 1 and rownum <= 50"
It???s giving me first 50 OBJECTID's but if I do query.where= "rownum >= 51 and rownum <= 100"
It???s giving me 0 records.

Any idea?

This way I am doing pagination because I have more than 3 million records for some layers.
if I do query.where="1 = 1". The app is freezing.


Thanks !!
-Naveen
Tags (2)
0 Kudos
4 Replies
IvanBespalov
Occasional Contributor III
Here is good explanation why it happens - http://www.oratable.com/rownum/
...ROWNUM is a pseudocolumn that assigns a number to every row returned by a SQL query. It can be of great use in filtering data based on the number of rows returned by the query.

ROWNUM gets its value as the query is executed, not before, and gets incremented only after the query passes the WHERE clause. Therefore, your WHERE condition can filter data based on "rownum < 2/3/4/." but not "rownum > 2/3/4.". The second filter will invariably return no rows selected.


Good luck.

P.S. from api reference
Query -> where
...
Other examples: query.where = "OBJECTID BETWEEN 1 AND 10"
...


It works perfectly.
0 Kudos
NaveenKatta
New Contributor III
Thanks for your reply. If we know the OBJECTID ('OBJECTID BETWEEN 1 AND 10')will works as expected.

But first thing how to know the OBJECTID?? I am querying to know the OBJECTID like first 50 and after 2nd set of 50......

Thanks!!
-Naveen(NY State)
0 Kudos
IvanBespalov
Occasional Contributor III
But first thing how to know the OBJECTID?


QueryTask.executeForIds()

From ArcGIS server REST help:
returnIdsOnly:
Description: If true, the response only includes an array of object IDs. Otherwise the response is a feature set. The default is false.
Note that while there is a limit on the number of features included in the feature set response, there is no limit on the number of object IDs returned in the ID array response. Clients can exploit this to get all the query conforming object IDs by specifying returnIdsOnly=true and subsequently requesting feature sets for subsets of object IDs.
0 Kudos
DasaPaddock
Esri Regular Contributor
0 Kudos