Newbie question on returned rows
Posted in 1999
Topics: General Discussion
Hello all, What is the "set" statement that sets the limit of rows returned by a select statement. Also, what statement would return the last row? Thanks in advance for your help. -Wazir wshpoon@winstar.com
Wazir Shpoon wrote:
>
> Hello all,
>
> What is the "set" statement that sets the limit of rows returned by a select
> statement. Also, what statement would return the last row? Thanks in
> advance for your help.
There are no such commands, in general. If you are using version 7.30 or
later, it is always a good idea to post your platform and engine versions
so we can tailor our answers, you can use the "FIRST N" clause in the
SELECT statement itself to limit the query, thus:
SELECT FIRST 10 *
FROM tablename....
The only way to fetch ONLY the last N rows is if you are willing to use
a SCROLL cursor in a front-end language (ie ESQL/C, 4GL, DBD/DBI Informix,
etc.). With a scroll cursor a temp table is automatically created for the
querie's result set and you can use FETCH FIRST, FETCH LAST, FETCH NEXT,
FETCH PREVIOUS, FETCH ABS n (meaning the nth row in the select set).
Check all this in the Guide to SQL Reference and Syntax manuals.
Art S. Kagel