SWITCH command
This dynamic command causes a data store file switch for a specific file group. At any given time, update-type operations against tables in a particular group are directed to one and only one of the files in the group. That one file is called the active file. A file switch changes the active file for a group. In other words, the switch causes a file other than the currently active one to become the new active file.
If the group specified by this command has only one file, or the group currently has no inactive file that is eligible for output, the switch is not performed.
At the conclusion of a switch, persistent data store starts the maintenance process for a file in the group if no empty files remain in the group.
The [NO]EXTRACT keyword can be used to force or suppress an extract job for the data store file deactivated by the switch.
Syntax
SWITCH GROUP=groupid [ EXTRACT | NOEXTRACT ]
where
- groupid
- Specifies the ID of the file group that is to be switched. The group must have multiple files assigned to it.
- EXTRACT
- Specifies that the deactivated data store file is to be extracted, even if the file's GROUP statement did not request extraction.
- NOEXTRACT
- Specifies that extraction is not to be performed for the deactivated data store file. This option overrides the EXTRACT keyword of the GROUP statement.
Note that if neither EXTRACT nor NOEXTRACT is specified, the presence or absence of the EXTRACT keyword on the file's GROUP statement determines whether extraction is performed as part of the switch.
SWITCH logic
The SWITCH command looks at all data sets assigned to the group and attempts to find an empty one. If no empty data sets are available, future attempts to write data to any data set in the group will fail. Normally, an empty data set is found and is marked as the active data set.When a data set is deactivated because it is full, it is tested to see whether the EXTRACT option was specified. If so, the EXTRACT command for the data set is executed.
The next test is to check whether there are any empty data sets in the current group. If not, the code finds the data set with the oldest data and marks it for maintenance. With the latest release of the persistent data store, the code checks to see whether any of the maintenance options BACKUP, EXPORT, or EXTRACT were specified for this data set. If not, the INITDS command is executed. Otherwise, the BACKUP command is executed.