LucidDbAppLib TOPN
From Eigenpedia
Contents |
Syntax
select * from table(
applib.topn(IN_CURSOR, NUMBER_OF_ROWS)
);
Purpose
Extract the first <NUMBER_OF_ROWS> rows of a table.
Parameters
Input:
- IN_CURSOR cursor: cursor to the original table.
- NUMBER_OF_ROWS integer: the number of rows from the IN_CURSOR to return.
Output:
- The <NUMBER_OF_ROWS> first rows of <IN_CURSOR>.
- If <NUMBER_OF_ROWS> is greater than the number of rows in <IN_CURSOR> then all rows are returned.
- If <NUMBER_OF_ROWS> is less than or equal to 0 no rows are returned.
Exceptions
- NullPointerException if <NUMBER_OF_ROWS> is null
Examples
select schema_name from sys_root.dba_schemas order by schema_name; +---------------------+ | SCHEMA_NAME | +---------------------+ | APPLIB | | INFORMATION_SCHEMA | | JDBC_METADATA | | MGMT | | SQLJ | | SYS_BOOT | | SYS_ROOT | | TEMP | +---------------------+ select * from table(applib.topn(cursor( select schema_name from sys_root.dba_schemas order by schema_name ), 2)); +---------------------+ | SCHEMA_NAME | +---------------------+ | APPLIB | | INFORMATION_SCHEMA | +---------------------+
Source Code
http://p4web.eigenbase.org/open/dev/luciddb/src/com/lucidera/luciddb/applib/cursor/TopNUdx.java

