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.
Users must have the CONNECT privilege on the new location, as well as authority to access and/or modify objects stored at that location.
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.
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.
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).