ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Trigger vs journal

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trigger vs journal

    Trigger and journal both can be use to log details but my question is what is the difference between these two and which method is good for log.

  • #2
    A journal's purpose is to record activity. You set it up and the system does the rest.
    A trigger is a custom program that you write when a certain event takes place.

    Logging is a journal's job.

    Comment


    • jtaylor___
      jtaylor___ commented
      Editing a comment
      A trigger is a custom program that you write, that fires when a certain event takes place.

  • #3
    but we can also log using trigger no?and which is better 4 logging

    Comment


    • #4
      Originally posted by jtaylor___ View Post
      ...
      Logging is a journal's job.

      Comment


      • #5
        This is sort of like asking "Should I watch the Weather Channel or install a window in my house?" I suppose they could serve the same purpose in some cases, but they're not really the same thing.

        A journal keeps track of every detail of everything that happens, and it's all done for you.

        A trigger lets you write code that happens when an insert/update/delete (or even read) is made. What that code does is entirely up to you.

        So just as the Weather Channel has tons of historical data, trends, accurate measurements from lots of different places, and detailed analysis of the weather, so also does a journal have tons of information. But this may be "information overload" if all you want to know is "who changed the price for order 1234?" On the other hand, the trigger won't do anything at all by itself. Much like a window doesn't tell you the weather, it's up to you to look out and analyze what you see... you'd have to write a program that logs whatever data you want to log, you'd have to debug it and make sure the code is perfect and doesn't ever fail to log what is needed. But, it has the advantage that the log can do exactly what you want -- so if you just want to know one simple piece of information, you can code it to only show that one piece of information, making the log much simpler to read. And, of course, triggers aren't limited to logging, they can do anything...

        Does that help?

        Comment


        • #6
          ... and your trigger will fail if you try to perform a CLRPFM, while there is no error when using a journal.
          (Whether it makes sense to clear a triggered file is another question, but one of our customers had this problem)

          Birgitta

          Comment


          • #7
            Thanks scott

            Comment

            Working...
            X