Rowset.rows()
This article is about the rows() function of the Rowset object.
Rowset.rows()
Addresses a record or a set of records of the row set.
Returns a UdbRows object.
Row selectors
The optional arguments passed to .rows() in the syntax block below are row selectors. They allow you to identify one or more specific records.
Syntax
$.udb( *ds* ).rowSet( *rowSet* ).rows( *index*, *index* )
$.udb( *ds* ).rowSet( *rowSet* ).rows( *keyword*, *indicator* )
The required ds parameter is a data source selector.
The required rowSet parameter is a rowset identifier.
The optional index, keyword, indicator are row selectors. If you do not pass a row selector, all records in the row set are addressed. If you do pass a row selector, you either pass one or two index arguments, or you pass a keyword argument that possibly requires an indicator argument.
Passing row selectors
Index values are integers or arrays used to identify records in the row set:
- 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, not1.
Examples
This example addresses the 5th record:
$.udb('EMP').rowSet('current').rows(4);
This example addresses the 5th up to and including the 10th record:
$.udb('EMP').rowSet('current').rows(4, 9);
This example addresses the records with the specified indices:
$.udb('EMP').rowSet('current').rows([0, 1, 4, 7]);
Passing keyword and indicator values
Each keyword value is a string that identifies a predefined option. If the Indicator column is empty, the indicator parameter does not apply; 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') |
Examples
This example addresses the records of the current data set:
$.udb('EMP').rowSet('current').rows('dataset');
This example addresses the records of data set 2:
$.udb('EMP').rowSet('current').rows('dataset', 2);
This example gets records that satisfy the equality condition EMPNO = 10:
$.udb('EMP').rowSet('current').rows({ EMPNO: '10' });
These examples get records that satisfy more complex conditions:
$.udb('EMP').rowSet('current').rows('condition', { BIRTH_DATE: '>=01-JAN-1980' });
$.udb('EMP').rowSet('current').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').rowSet('current').rows('condition', { MANAGER: 'NULL', SALARY: '>35000' });
To get a record by row ID:
$.udb('EMP').rowSet('current').rows('id', 15);
In all cases, records have to be queried first before they can be found by any of these operations. To query, use executeQuery() first, and gotoDataSet() afterwards if needed.