Skip to content

Instantly share code, notes, and snippets.

@chukShirley
Created December 12, 2017 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chukShirley/32fbae2b82a94114f44e93e20c62b96b to your computer and use it in GitHub Desktop.
Save chukShirley/32fbae2b82a94114f44e93e20c62b96b to your computer and use it in GitHub Desktop.
Start Journal Physical File for all table objects in a library
<?php
$library = 'MYLIB';
$journalLibrary = 'MYLIBJRN';
$journal = 'JRNL';
// Use DB2 for i service
$connection = db2_connect('*LOCAL', '%USER%', '%PASSWORD%');
$sql = 'SELECT * FROM QSYS2.TABLES where table_schema=? and table_type=? order by table_name asc';
$params = [$library, 'BASE TABLE'];
$statement = db2_prepare($connection, $sql);
$result = db2_execute($statement, $params);
while ($row = db2_fetch_assoc($statement)) {
$row = array_map('trim', $row);
$command = 'STRJRNPF FILE(' . $row['TABLE_SCHEMA'] . '/' . $row['TABLE_NAME'] . ' JRN(' . $journalLibrary . '/' . $journal . ')';
shell_exec("system '$command'");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment