Automatically starting journaling

You can automatically journal objects created into libraries or directories.

  • Objects created in, moved into, or restored into a journaled library will automatically start journaling. To start library journaling, see Journaling libraries.
  • Using a data area named QDFTJRN, you can automatically start journaling for a non-integrated file system object. The QDFTJRN data area must be created by the user.
  • To automatically start journaling for integrated file system objects, see the discussion of journal inheritance in Journaling integrated file system objects.

Automatic journaling using QDFTJRN

Using data area named QDFTJRN, you can automatically start journaling when a non-integrated file system object (data area, data queue, or file) is created, moved, or restored into the library, thus, ensuring the very first change to the object will be recorded in the journal and that no lock on the user's part prevents journaling from starting in the library. The QDFTJRN data area must exist in the library where the object is being added.

If a data area called QDFTJRN exists 1) in the same library into which the data area, data queue, or physical file is created, or 2) in the same schema that the SQL table is created into, and 3) the user (in either instance) is authorized to the data area, journaling will be started to the journal named in the data area if all the following are true:

  • The identified library for the data area, data queue, or physical file or identified schema for the SQL table must not be QSYS, QSYS2, QRECOVERY, QSPL, QPTFOBJ1, QPTFOBJ2, QRCL, QRPLOBJ, QGPL, QTEMP, or any of the independent auxiliary storage pool (IASP) equivalents to these libraries. (An iASP equivalent of QRPLOBJ, for example, is QRPLxxxxx where 'xxxxx' is the number of a primary auxiliary storage pool (ASP).)
  • The journal specified in the data area must exist and the user must be authorized to start journaling to the journal.

See Table 1 for a detailed description of the values within the data area. When creating SQL tables within a schema, the QSQJRN journal within the schema is used to start journaling the tables. To start journaling the tables to a different journal than QSQJRN within the schema, create the QDFTJRN data area in the schema and specify a different journal name inside the QDFTJRN data area.

Table 1. Formats of the QDFTJRN data area.
Offset Field Format Description
1 Library name Char (10) Name of the library that contains the journal.
11 Journal name Char (10) Name of the journal to use to automatically start journaling.
21 Repeat the set of Object type and Option as needed:
  Object type Char (10)

Object type value:

  • *FILE = database files or SQL tables
  • *DTAARA = data areas
  • *DTAQ = data queues
  • *ALL = all journal eligible objects which are not in an integrated file system
  • *NONE = no objects
  Option Char (10)

Option:

  • *CREATE = Start journaling when an object is created into the library
  • *MOVE = Start journaling when an object is moved into the library
  • *RESTORE = Start journaling when an object is restored into the library
  • *ALLOPR = Start journaling in all cases possible
  • *RSTOVRJRN = Override the saved object's journal and start journaling to the journal name in this QDFTJRN data area when the object is restored into the library
Note: The values in the data area must be in upper case.

Restore impacts for library-based objects

Library journaling and the QDFTJRN data area provide more options for journaling during the restore operation. When using the *RESTORE keyword, even if an object was not journaled at save time, the operating system automatically records the restore operation to the journal the library is journaled to, or to the journal specified in the QDFTJRN data area. However, if the object was journaled at save time and that journal still exists on the system, the library's journal and the journal specified in the QDFTJRN data area are ignored. In this case, the operating system still records the restore operation to the journal used at save time.

You can use the *RSTOVRJRN keyword to override the journal used at save time. After you specify the *RSTOVRJRN keyword, the operating system always records the restore operation to the library's journal or to the journal that is specified in the QDFTJRN data area. In this case, any journal used at save time is ignored.

If the object being restored still exists on the system, the *RSTOVRJRN keyword is ignored during the restore operation.

If you changed the journal of your object using the *RSTOVRJRN keyword, save your object as soon as possible to enable future recovery operations with the Apply Journaled Changes (APYJRNCHG), Apply Journaled Changes Extend (APYJRNCHGX), and Remove Journaled Changes (RMVJRNCHG) commands. The save operation records the journal receiver and the new journal as the journal receiver and journal to use for recovering your object from the point of its last save. The save operation also updates the last saved date of your object, if UPDHST(*YES) is specified on the save command.

See the Start Journal Library (STRJRNLIB) command for more information on using the *RSTOVRJRN keyword with library journaling.

To use the *RSTOVRJRN keyword to override the journal used at save time, position the *RSTOVRJRN keyword in the QDFTJRN data area before the references to the *ALLOPR or *RESTORE operation option. Here is an example.

For example, the files restored into library OVERRIDE are currently journaled to journal SAVEJRN in library SAVELIB. But you want the files to be journaled to journal OVERJRN in library JRNLIB, while you still want the restored data areas or data queues to be journaled to the save time journal. And you also want any new objects created into the library OVERRIDE to be journaled to journal OVERJRN in library JRNLIB. To achieve this, use the following commands to create the QDFTJRN data area.
CRTDTAARA DTAARA(OVERRIDE/QDFTJRN) TYPE(*CHAR) LEN(80)                       
CHGDTAARA DTAARA(OVERRIDE/QDFTJRN (1 10)) VALUE(JRNLIB)                      
CHGDTAARA DTAARA(OVERRIDE/QDFTJRN (11 10)) VALUE(OVERJRN)                    
CHGDTAARA DTAARA(OVERRIDE/QDFTJRN (21 10)) VALUE(*FILE)                      
CHGDTAARA DTAARA(OVERRIDE/QDFTJRN (31 10)) VALUE(*RSTOVRJRN)                 
CHGDTAARA DTAARA(OVERRIDE/QDFTJRN (41 10)) VALUE(*ALL)                       
CHGDTAARA DTAARA(OVERRIDE/QDFTJRN (51 10)) VALUE(*ALLOPR)   
Note: The library and journal names in columns 1-20 must be in upper case.