The RRN function returns the relative record number of a row.
In SQL naming, the table name may be qualified. In system naming, the table name cannot be qualified.
If the argument identifies a view, common table expression, or derived table, the function returns the relative record number of its base table. If the argument identifies a view, common table expression, or derived table derived from more than one base table, the function returns the relative record number of the first table in the outer subselect of the view, common table expression, or derived table.
If the argument identifies a distributed table, the function returns the relative record number of the row on the node where the row is located. If the argument identifies a partitioned table, the function returns the relative record number of the row in the partition where the row is located. This means that RRN will not be unique for each row of a partitioned or distributed table.
The argument must not identify a view, common table expression, or derived table whose outer subselect includes an aggregate function, a GROUP BY clause, a HAVING clause, a UNION clause, an INTERSECT clause, or DISTINCT clause. The RRN function cannot be specified in a SELECT clause if the subselect contains an aggregate function, a GROUP BY clause, or a HAVING clause. If the argument is a correlation name, the correlation name must not identify a correlated reference.
The data type of the result is a decimal with precision 15 and scale 0. The result can be null.
SELECT RRN(EMPLOYEE), LASTNAME FROM EMPLOYEE WHERE DEPTNO = 20
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.