Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search for triggers in a schema in DB2 9.7?

Tags:

sql

database

db2

I have a list of tables in a schema in IBM DB2 9.7. Some of them have triggers and others do not. I am creating a stored procedure that goes through all tables in SYSCAT.TABLES, but how do I check with sql syntax if that table has a trigger with a specific name? (or any trigger)

like image 240
user1340582 Avatar asked Aug 17 '12 06:08

user1340582


1 Answers

You can use the SYSCAT.TRIGGERS catalog view.

SELECT *
FROM SYSCAT.TRIGGERS
WHERE TABNAME    = @table_name
  AND TABCREATOR = @table_schema
  AND TRIGNAME   = @trigger_name
  AND TRIGSCHEMA = @trigger_schema

The predicates given are just examples of columns you might search by, you can obviously pick and choose based on your needs.

like image 53
bhamby Avatar answered Sep 21 '22 16:09

bhamby