DATASLICEID pseudocolumn
Any unresolved and unqualified column reference to the DATASLICEID pseudocolumn is converted to NODENUMBER function and returns the database partition number for a row. For example, if DATASLICEID is used in a SELECT clause, the database partition number for each row is returned in the result set.
The specific row (and table) for which the database partition number is returned by DATASLICEID is determined from the context of the SQL statement that uses it.
The database partition number returned on transition variables and tables is derived from the current transition values of the distribution key columns.
- A column within the current SQL query
- A local variable
- A routine parameter
- A global variable
Avoid using 'DATASLICEID' as a column name or a variable name while DATASLICEID pseudocolumn is needed. All limitations of the DBPARTITIONNUM function (and its alternative, the NODENUMBER function) apply to the DATASLICEID pseusocolumn.
Examples
- Example 1
- The following example counts the number of instances in which
the row for a given employee in the EMPLOYEE table is on a different
database partition from the description of the employee's department
in the DEPARTMENT table:
SELECT COUNT(*) FROM DEPARTMENT D, EMPLOYEE E WHERE D.DEPTNO=E.WORKDEPT AND E.DATASLICEID <> D.DATASLICEID
- Example 2
- The following example joins the EMPLOYEE and DEPARTMENT tables
so that the rows of the two tables are on the same database partition:
SELECT * FROM DEPARTMENT D, EMPLOYEE E WHERE E.DATASLICEID = D.DATASLICEID