CURRENT DBPARTITIONNUM special register

The CURRENT DBPARTITIONNUM special register specifies an INTEGER value that identifies the coordinator database partition number for the statement.

For statements issued from an application, the coordinator is the database partition number to which the application connects.

For statements issued from a routine, the coordinator is the database partition number from which the routine is invoked.

When used in an SQL statement inside a routine, CURRENT DBPARTITIONNUM is never inherited from the invoking statement.

CURRENT DBPARTITIONNUM returns 0 if the database instance is not defined to support database partitioning. For a partitioned database, the db2nodes.cfg file exists and contains database partition and database partition number definitions.

In a database partitioning environment, the CURRENT DBPARTITIONNUM special register can be changed through the CONNECT statement, but only under certain conditions.

Examples

Example 1: Set the host variable APPL_DBPNUM (integer) to the number of the database partition to which the application is connected.
   VALUES CURRENT DBPARTITIONNUM
     INTO :APPL_DBPNUM
Example 2: The following command is issued on member 0 and on a 4 member system in a partitioned database environment. This query will retrieve the currently connected database partition number.
   VALUES CURRENT DBPARTITIONNUM

   1          
   -----------
             0