Declarative Objectivity (DO) Language : Data Clauses : TAKE WHILE Clause
TAKE WHILE Clause
A TAKE WHILE clause modifies a RETURN Statement so that it returns objects only when a specified test is true.
Syntax 
takeWhileClause : TAKE WHILE expression;
Used In 
RETURN Statement
Quick Look 
Find customers, order them by last name, and then return just the ones whose names begin with “A”):
FROM Customers ORDER BY lastName TAKE WHILE lastName =~~ '^A.*' RETURN * ;
Find customers, order them by last name, and then return just the ones whose names begin with “B”:
FROM Customers ORDER BY lastName SKIP WHILE lastName =~~ '^A.*' TAKE WHILE lastName =~~ '^B.*' RETURN * ;
Discussion 
A TAKE WHILE clause causes a RETURN statement to return objects as long as they satisfy a specified condition. Testing starts with the first result to be returned (or with the first result following any that are omitted a SKIP or SKIP WHILE clause). If that first object does not satisfy the condition, no results are returned.
You can use TAKE WHILE together with the SKIP WHILE Clause in successive executions of a query to partition the result set according to a series of tests. The first time you execute the query, you typically use TAKE WHILE by itself to return the first “partition” (results that meet the first test). In the second execution, you add SKIP WHILE to omit the “partition” you’ve already returned, and use TAKE WHILE to obtain the “partition” that meets the second test. In the third execution, you adjust the argument of SKIP WHILE to omit the first two “partitions”, and adjust TAKE WHILE to obtain the “partition” that meets the third test, and so on.
Note:You typically include an ORDER BY Clause so that results can be partitioned effectively.
See also SKIP Clause, SKIP WHILE Clause, TAKE Clause.