Skip to content

Journaling

A Db2 for i Capture Agent reads a table's changes from its journal, so every physical file (table) you replicate incrementally must be journaled, with before and after images (IMAGES(*BOTH)). SQDR asks for before images, so a table journaled with after images only is rejected when you subscribe to it ("Invalid journaling/logging options"). Two exceptions: a subscription whose destination is keyed by the relative record number (RRN) doesn't need before images (see The RRN or ROWID column), and the agent accepts after-only tables when its relaxedJournalCheck property is true (see Before and after images).

Start journaling

  1. Let the agent do it (autojournaling). Agents created with the Add Capture Agent wizard start journaling a table when you subscribe to it (property autoJournal). See Autojournaling.
  2. Start Journal Physical File (STRJRNPF) for each file, to a journal you created (see Create unique journals). The agent itself uses:

    STRJRNPF FILE(MYLIB/MYFILE) JRN(MYLIB/MYJRN) IMAGES(*BOTH) OMTJRNE(*OPNCLO)
    
  3. Data area QDFTJRN in the library, or

  4. Start Journal Library (STRJRNLIB): files created in the library from then on are journaled automatically (existing files aren't). For example, with before and after images:

    STRJRNLIB LIB(MYLIB) JRN(MYJRNLIB/QSQJRN) INHRULES((*ALL *ALLOPR *INCLUDE *BOTH))
    

    See the IBM i documentation.

Create the journal and its receivers first if they don't exist. In IBM i Access Client Solutions (and the heritage IBM Navigator for i), you can also right-click a table and choose Journaling to start journaling it.

Change a table from AFTER to BOTH

  • CHGJRNOBJ OBJ((MYLIB/MYTABLE *FILE)) ATR(*IMAGES) IMAGES(*BOTH). It needs an *EXCLRD lock on the table.
  • Or end and start journaling again (ENDJRNPF, then STRJRNPF with IMAGES(*BOTH)). Note the journaling attributes you set before, so that you can specify them again.
  • Or in IBM i Access Client Solutions: right-click the table, choose Journaling, and select Journal images before change.

For what changes with each setting, see Before and after images.

Check whether a file is journaled

Use DSPOBJD (or WRKOBJ MYLIB/MYFILE and option 8):

DSPOBJD OBJ(MYLIB/MYFILE) OBJTYPE(*FILE) DETAIL(*FULL)

Page down to Journaling information: Currently journaled must be YES, Current or last journal and Library name the journal, for example QSQJRN, and Journal images shows *BOTH or *AFTER. DSPFD FILE(MYLIB/MYFILE) shows the journal images too.

Other ways to check:

  • IBM i Access Client Solutions: right-click the table and choose Journaling. It shows whether the table is journaled, to which journal, and whether Journal images before change is selected (*BOTH).
  • SQDR Control Center: Add Publication on the agent's Publications tab lists the tables it finds with their journaling (see Publish tables). View Metadata on the Subscriptions tab gives the journal information of subscribed tables (see Manage an agent's subscriptions).

List the tables of a journal

To see which tables are journaled to a journal, for example to find the subscriptions whose backlog keeps its receivers, or the tables of a journal the agent reports an authority problem for:

WRKJRNA JRN(MYLIB/MYJRN)

Then press F19 (Display journaled objects).