Find Trigger Program

Article ID: 56880

Q: I have a program that I use as a database trigger. I know that it's attached to many files, but I don't know which ones. Given the program name, how can I see which files it's attached to?

Q: The operating system maintains a database file, SYSTRIGGER, that contains information about all the triggers on the system. With this database file in mind, you could, for example, write an SQL query that lists the files that use a given program name:

select TabName from SYSTRIGGER where TrigPgm='Your Program Name'

Or if you wanted something a little fancier, you could do this:

select substr(tabSchema,1,10) as Library,
       substr(TabName,1,10) as File,
       TrigTime as Time,
       TrigEvent as Event                    
 from SYSTRIGGER                                     
where TrigPgm='Your Program Name'
  and TrigPgmLib='Library Containing Program'

In my opinion, PRTTRGPGM serves a different purpose. PRTTRGPGM is for reporting the triggers that are attached to files in a given library. It doesn't provide any direct way to locate a file based on the program name. Sure, you could dump all of the triggers in *ALLUSR libraries to the spool, then search the spooled file -- but that seems like a lot of work. Surely a simple SQL statement is easier? (At least, it would be for a programmer -- which is the target audience of this newsletter.)

But, of course, in another situation you might want to list all of the triggers in a library (or all libraries) and in that case, PRTTRGPGM would be a very useful tool indeed.

Or you can use PRTTRGPGM--that will search a library or *ALLUSR libraries creating a report of the file/programs.

ProVIP Sponsors

ProVIP Sponsors