1

My question is very simple, i'm working with WebSphere Commerce and DB2 , i have my own trigger on db2 . I need to see on a log file when the trigger starts and when the trigger ends . Which log file have this information on DB2?

Grettings from Peru!

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
Diego
  • 13
  • 5
  • DB2 on what platform? DB2 on i can maintain triggers separately, but logging of trigger times isn't exactly a built in feature. – user2338816 Jun 18 '14 at 23:33

1 Answers1

2

Triggers are not executed separately from SQL statements that fire them; they are actually compiled in to the statement that causes the trigger to fire.

If you need to know when triggers are firing you'll need to make the trigger perform the logging actions you require. Keep in mind that triggers occur within the transaction scope, so any changes your trigger makes (e.g., inserting into a log table) will be rolled back with the rest of the transaction.

For auditing purposes you would need to handle this logging via an autonomous procedure (which occurs outside of the scope of the rest of the transaction).

Ian Bjorhovde
  • 10,916
  • 1
  • 28
  • 25
  • Hi Ian, i was following your suggestion. I did a 'logging store procedure' in the same schema of trigger. Everything was ok, the store procedure write in a text file called 'myLoggin.log'. But now, i have this issue, when the trigger is firing, in the 'CALL myProcedure' line of trigger DB2 says this : An error occurred in a triggered SQL statement in trigger "DB2INST1.DIEGOTR". Information returned for the error includes SQLCODE "-746", SQLSTATE "57053" and message tokens "SYSIBMADM.UTL_DI|UTL_DIR_GET_DIRECTORY_PAT". – Diego Jun 19 '14 at 17:29
  • Did you look up the -746 error? (`db2 "? sql0746n"`) – Ian Bjorhovde Jun 20 '14 at 17:29