Db2 – Determine if existing Trigger acts on field DB2

db2trigger

I am eventually going to be writing a trigger on a field named "user2". Currently most of the values in this field are blank, but there are some seemingly random rows with values of '00' for the field.

What I was wondering, is there anyway to determine if there is an existing trigger that is adding these values to the field? If not, what are some methods I can use to figure out how this data is getting there?

Thanks,

Andrew

Best Answer

If you are asking if you can determine if the table in question has any triggers defined, then yes - you can either

  • Look at the view SYSCAT.TRIGGERS, filtering on the TABSCHEMA and TABNAME columns
  • Extract the DDL for the table using the db2look command.

If you are asking if there's any way to determine whether existing rows that have a value were updated as a result of an existing trigger, then the answer is no. There is nothing inherent to triggers that would allow you to identify them as the source of the data in the column. The trigger could contain some logic to identify itself as the source of the value, but that would be stored in some other column or table.