SET LOCATION TO

The SET LOCATION command logs a user onto a new location, creating an implied connection between the user's sessions and the specified location. The value of the CURRENT SERVER special register is also updated to reflect the new active location.
Restriction: This topic applies to Windows environments only.

Invocation

SET LOCATION is an executable XDB Server utility command that can be issued interactively or embedded in a host language. SET LOCATION can be dynamically prepared.

Authorization

Users must have the CONNECT privilege on the new location, as well as authority to access and/or modify objects stored at that location.

Syntax

SET LOCATION TO location-name

Parameters:

location-name Identifies a location accessible to the XDB Server.

Description

All XDB Server operations are performed and recorded under the currently set (or default) XDB Server location. The default value of the CURRENT SERVER special register is maintained in the XDB Server configuration file CONFIG.XDB. To create objects in a location other than the current location, use the SET LOCATION statement prior to entering other SQL statements.

Use of this command does not permanently change the user's current location, but only sets the location for the commands that immediately follow. The location remains set until the user either issues another SET LOCATION command or exits the utility where the SET LOCATION command was issued.

The SET LOCATION command differs in several respects from the CONNECT command. The CONNECT command can be used only in embedded SQL, and refers solely to locations recorded in the SYSIBM.SYSLOCATIONS catalog table (which includes remote locations). The SET LOCATION command, also refers to locations recorded in the SYSXDB.SYSLOCALS catalog table (which must be local).

XDB Link Locations

If you issue a SET LOCATION command to an XDB Link location, you cannot return to your XDB Server by issuing another SET LOCATION command (DB2 cannot read XDB Server catalog tables). If your application needs this type of functionality, use the CONNECT and CONNECT RESET commands from embedded SQL.

Example:

Take a typical scenario where the user is connected to LOC1 as the current default location, but the user needs to temporarily access another location (LOC2) in order to create a database object there. This user could access SQLWizard and issue the following command:

SET LOCATION TO loc2

All transactions for that user in the current (old) location are automatically committed and acquired locks released. Any SQL commands issued next (object creation or otherwise) operate on the new location specified above. When the user exits SQLWizard, the original default location (LOC1) returns.

Note:

The XDB Server 2.4x (and earlier) SET DATABASE command syntax can still be used to change the active location. However, a location name must be used for the argument.