CURRENT SERVER

CURRENT SERVER specifies the location name of the current server.

The data type is CHAR(16). If necessary, the location name is padded on the right with blanks so that its length is 16 bytes.

The initial value of CURRENT SERVER depends on the CURRENTSERVER bind option. If CURRENTSERVER X is specified on the bind subcommand, the initial value is X. If the option is not specified, the initial value is the location name of the local DB2®. The initial value of CURRENT SERVER in a user-defined function or stored procedure is inherited according to the rules in Table 1. The value of CURRENT SERVER is changed by the successful execution of a CONNECT statement.

The value of CURRENT SERVER is a string of blanks when either of the following conditions apply:

  • The application process is in the unconnected state
  • The application process is connected to a local DB2 subsystem that does not have a location name.
Example: Set the host variable CS to the location name of the current server.
 EXEC SQL SET :CS = CURRENT SERVER;