Row selectors
Row selectors are used to indicate a set of rows in a UdbRows object. Its result is always the UdbRows object, which holds a collection of UdbRecord objects that match the parameters of the selectors.
Usage
The row selectors are passed to any .rows() function call in a Rowset or DataSource object:
$.udb( *ds* ).rows( *index*, *index* )
$.udb( *ds* ).rows( *keyword*, *indicator* )
$.udb( *ds* ).rowSet( *rowSet* ).rows( *index*, *index* )
$.udb( *ds* ).rowSet( *rowSet* ).rows( *keyword*, *indicator* )
See also the .rows() function.
Syntax
.rows( [index], [index] )
.rows( [keyword], [indicator] )
*index* ::= Integer
*keyword* :: 'current' | 'selected' | 'condition' | 'first' | 'last' | 'next' | 'previous' | 'id' | 'marked' | 'keystring' | 'dataset'
When using the index parameters, you can either refer to a single record, or a set range of records. When only specifying a single index, then a single record is returned. A combination of indices returns the records matching these indices, and those in-between them.
Index values are integers or arrays used to identify records in the data source:
- If you pass a single integer value, the record that corresponds to that index value is addressed.
- If you pass two integer values, the records corresponding to the first and the second index value are addressed and also all the records in between.
- If you pass an array of integer values, the records corresponding to the elements in the array are addressed.
- The index is 0-based: the first item has index 0, not 1.
When using the keyword parameter, you can select a more diverse set of records. The keyword parameter is a string value, and each value of keyword is a string that identifies a predefined option, see the table below.
If the Indicator column is empty, the indicator parameter does not apply and must be omitted; otherwise, the indicator stated is required.
| Keyword | Indicator | Description |
|---|---|---|
'current' | The current record (not the same as 'selected') | |
'dataset' | data set indicator | The records in the requested data set |
'condition' | condition | The record(s) that satisfy the condition |
'first' | The first record | |
'id' | row ID | The record with the requested row ID |
'last' | The last record | |
'marked' | All marked records | |
'next' | The record following the current record | |
'previous' | The record preceding the current record | |
'selected' | All selected records (not the same as 'current') | |
'keystring' | Key string of a row | The record matching the specified key string |
Examples
This example addresses the 5th record:
$.udb('EMP').rows(4);
and is short for:
$.udb('EMP').rowSet('current').rows(4);
This example addresses the 5th, 6th and 7th record:
$.udb('EMP').rows(4, 6);
This example addresses the records with the specified indices:
$.udb('EMP').rowSet('current').rows([0, 1, 4, 7]);
This example addresses the record following the current record:
$.udb('EMP').rows('next');
This example addresses the records in the first data set:
$.udb('EMP').rows('dataset', 1);
This example gets records that satisfy the equality condition EMPNO = 10:
$.udb('EMP').rows( { EMPNO: '10' } );
These examples get records that satisfy more complex conditions:
$.udb('EMP').rows('condition', { BIRTH_DATE: '>=01-JAN-1980' } );
$.udb('EMP').rows('condition', { BIRTH_DATE: '>=01-JAN-1980&<=01-JAN-2000' } );
To get all rows where MANAGER is NULL and SALARY is higher than 35000:
$.udb('EMP').rows('condition', { MANAGER: 'NULL', SALARY: '>35000' } );