Examples of NODENAME with DB2® Multisystem
Here is an example about how to use the NODENAME function.
- Find the node name and the partition number for every row of the EMPLOYEE table, and the corresponding value of the EMPNO columns for each row. SQL statement:
SELECT NODENAME(CORPDATA.EMPLOYEE), PARTITION(CORPDATA.EMPLOYEE), EMPNO FROM CORPDATA.EMPLOYEE
- Find the node name for every record of the EMPLOYEE table. OPNQRYF command:
OPNQRYF FILE((CORPDATA/EMPLOYEE)) FORMAT(FNAME) MAPFLD((NODENAME '%NODENAME(1)'))
- Join the EMPLOYEE and DEPARTMENT tables, select the employee number (EMPNO) and determine the node from which each row involved in the join originated. SQL statement:
SELECT EMPNO, NODENAME(X), NODENAME(Y) FROM CORPDATA.EMPLOYEE X, CORPDATA.DEPARTMENT Y WHERE X.DEPTNO=Y.DEPTNOOPNQRYF command:OPNQRYF FILE((CORPDATA/EMPLOYEE) (CORPDATA/DEPARTMENT)) FORMAT(FNAME) JFLD((EMPLOYEE/DEPTNO DEPARTMENT/DEPTNO *EQ)) MAPFLD((EMPNO 'EMPLOYEE/EMPNO') (NODENAME1 '%NODENAME(1)') (NODENAME2 '%NODENAME(2)'))
- Join the EMPLOYEE and DEPARTMENT tables, select all rows of the result where the rows of the two tables are on the same node. SQL statement:
SELECT * FROM CORPDATA.EMPLOYEE X, CORPDATA.DEPARTMENT Y WHERE NODENAME(X)=NODENAME(Y)OPNQRYF command:OPNQRYF FILE((CORPDATA/EMPLOYEE) (CORPDATA/DEPARTMENT)) FORMAT(FNAME) JFLD((1/NODENAME1 2/NODENAME2 *EQ)) MAPFLD((NODENAME1 '%NODENAME(1)') (NODENAME2 '%NODENAME(2)'))
Parent topic:
NODENAME with DB2 Multisystem