Introduction
Imagine you're keeping a diary of everything that happens in your day - what you ate, where you went, what you bought. If you ever forget something or lose something, you just flip through your diary to find out what happened.
Now imagine your IBM i system doing the same thing.
That’s what Journaling is!
In this blog, we’ll use a few simple analogies from diaries and CCTV cameras to undo buttons and bank transfers to help you build a clear mental model of journaling in IBM i.
What is Journaling?
Journaling in IBM i is like the system’s personal diary. It keeps track of:
- Every time you add, change, or delete something in the database.
- If a program crashes, you can check the journal to find out what was happening.
- During power outages, you can recover data by reading the last entries.
TIP: It’s like pressing Ctrl+S every second - automatically!
Why Do We Need Journaling?
Let’s look at a few real-world analogies that make the need for journaling easier to grasp:
Situation
|
Real Life Analogy
|
IBM i Equivalent
|
Auto-save in Google Docs
|
You never lose your writing even if your laptop crashes
|
Journaling saves data changes automatically
|
Undo Button
|
You undo the last thing you typed
|
You can rollback database changes
|
CCTV Camera
|
Helps you see who did what and when
|
Journaling tracks who changed which data
|
Flight Black Box
|
Records the plane’s last moments
|
Journaling helps you find out what went wrong if the system crashes
|
How Does It Work?
(Think of it like installing CCTV cameras in your store)
Here’s a more visual analogy:
- Journal Receiver = The DVR or cloud storage where all the recordings are saved.
- Journal = The control panel that connects your database files (like store areas) to the receiver.
- Database File = The area you want to monitor (e.g., cash counter or inventory).
- Start Journaling = Like turning on the cameras in that area - changes now start getting recorded.
- Replay or Audit = Watching the footage to review what happened at a specific time (for recovery or tracking).
Example Setup
(No need to memorize commands - this is just to understand the idea!)
CRTJRNRCV → Create a journal receiver (the DVR or storage box)
CRTJRN → Create a journal (the control panel that connects everything)
STRJRNPF → Start journaling a database file (turn on the camera for that area)
What If You Don’t Use Journaling?
Imagine these situations:
- You’re writing an essay but forget to save.
- You delete part of a spreadsheet and can’t undo it.
- Your app crashes, and you have no idea what data it was working on.
That’s your system without journaling - risky and blind.
What Happens During a Crash?
Let’s switch analogies for a moment. Imagine you’re updating a bank account:
- You're transferring ₹500 from Account A to Account B.
- Power goes out midway through the update.
Without journaling:
- The debit may have happened, but the credit didn’t - leaving your data inconsistent.
With journaling:
- IBM i can replay or undo the last steps and restore a safe state - just like reopening your diary or replaying CCTV footage to see what really happened.
Journaling + Transactions = Superpowers
When you run SQL like this:
BEGIN;
UPDATE balance SET amount = amount - 500 WHERE id = 1;
UPDATE balance SET amount = amount + 500 WHERE id = 2;
COMMIT;
IBM i uses journaling under the hood to track this as one atomic unit.
If anything fails, the system can roll it back - just like undoing a mistake in Word.
But this only works if your files are journaled!
Keeping Things Clean (Because Journals Grow!)
Your journal is like a diary - it gets thicker with every entry. So:
- Switch to a new receiver regularly (like starting a new diary).
- Save or delete old receivers (don’t let the pile grow forever).
IBM i lets you do this automatically: CHGJRN JRNRCV(*GEN)
In a Nutshell for Beginners
Term
|
Think of it as
|
Why it matters
|
Journal Receiver
|
A box of saved changes
|
Stores the details
|
Journal
|
A door to send changes into the box
|
Connects data to the log
|
Start Journaling
|
Turn on the logging
|
Begins tracking every change
|
End Journaling
|
Turn it off
|
Stops the tracking
|
Display Journal
|
View the diary
|
Shows what happened when
|
Final Words
You don’t need to be a system admin or a database guru to understand journaling. Just remember:
It's your system’s memory, undo button, and crash recovery tool - rolled into one!
Enable journaling where it matters, keep the logs clean, and sleep peacefully knowing your data is safe - even when things go wrong.