0

Say I have a C# script that creates 50 tables in MYLIB.

Currently, after running the script, I have to go into System i Navigator and manually attach the MYLIB/USRJRN to each of the tables' journaling.

How can I make my script do this instead?

1

You may start DB2 table journaling with the QSYS2.QCMDEXC procedure and a corresponding text of the STRJRNPF CL command as an argument. Something like this:

CALL QSYS2.QCMDEXC('STRJRNPF FILE(MYFILELIB/MYFILENAME) JRN(MYLIB/USRJRN) IMAGES(*BOTH) OMTJRNE(*OPNCLO)');
  • It works! Sort of. Only downside I see is that it will only work with the SYSTEM_TABLE_NAME, not the TABLE_NAME. Though, that can be fixed by a simple select from QSYS2.SYSTABLES. Is there a way to make it work directly with (longer than 10 characters) TABLE_NAME, though? – Sarov Sep 16 at 17:49
  • No afaik. So, it's better to create a stored procedure generating an appropriate command and calling QSYS2.QCMDEXEC routine based on TABLE_SCHEMA & TABLE_NAME user input. – Mark Barinstein Sep 16 at 17:58
0

If you create your library via the SQL CREATE SCHEMA command, then it will include a journal and journal receivers and all tables created in it will automatically be journaled.

Also, IBM offers the Start Journal Library (STRJRNLIB) command which lets you start default journaling on an existing library.

See also Automatically starting journaling for information about using QDFTJRN to start automatically start journaling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.