OFFSETKEY
is no longer maintained and will be removed in Starcounter 2.4. For most cases, OFFSETKEY
can be replaced by OFFSET
. If you're not able to replace OFFSETKEY
with OFFSET
, create an issue in github.com/Starcounter/Home/issues or as a question on StackOverflow and we'll help you out. Enumerator
(a cursor) with query result open. In addition to standard OFFSET clause, Starcounter SQL is extended with OFFSETKEY
clause, which re-creates the query enumerator and continues after the last retrieved record.OFFSETKEY
functionality is a good compromise. It provides for client side cursors with no server side state, just as OFFSET
does, but without the duplicate or missing records common with OFFSET
.OFFSET
query. Instead of a number indicating the position you should skip to, you instead retrieve a string value (the offset key) at the end of each portion. For the next portion, you provide the exact same query, but with the new key as a parameter value.FETCH
and OFFSETKEY
clauses and actual fetch and offset key values supplied. The first time the query is executed (i.e. for the first portion), the offset key value should always be set to null
or omitted.OFFSETKEY
clause is placed at the end of the SELECT
statement and can be together with FETCH clause, e.g.:null
as the OFFSETKEY.GetOffsetKey()
. The string key for OFFSETKEY clause, offset key, can be also retrieved from the query already having OFFSETKEY clause.OFFSETKEY
with ORDER BY
or GROUP BY
clauses.GetOffsetKey()
on enumerable or on enumerator, which is instance of IRowEnumerator
. Getting offset key on enumerable can be done only if one enumerator was open.GetEnumerator
, e.g.:GetOffsetKey
, which has the following signature:MoveNext
was called and was true
:Enumerator
and continue query execution, the query with offset key, offset key query, should be the same as the initial query, which was used to obtain the offset key, original query. Both query string and query variable values should be the same. Only FETCH
and OFFSETKEY
clauses can be different between queries. Note that OFFSET
and OFFSETKEY
clauses cannot be presented in the same query.FETCH
or OFFSETKEY
clauses and values), then Starcounter will throw an exception.null
, then the first row of the result of the offset key query will be the next row after the row of the original query, which was retrieved last before the offset key was gotten. The next row is defined for the moment when the offset key query is called. Thus if there were rows inserted after the last row of the original query, then the offset key query will retrieve them. Deleting the last row of the original query does not affect the result of the offset key query.null
value for OFFSETKEY
clause is equivalent to query with omitted OFFSETKEY
clause.