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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With