Problem solve Get help with specific problems with your technologies, process and projects.

Creating a DB2 trigger to execute a storage procedure

I have been tasked with creating a DB2 trigger to execute a stored procedure whenever a row is updated, added or deleted from several DB2 tables.

You should be able to pass the data you need from the trigger to your stored procedure. Just make sure that you build the stored procedure to accept the appropriate parameters, then send the correct data from within your trigger when you call the stored procedure.

IBM ships several examples of stored procedures with DB2. You should be able to find them in the sample library at your shop. Consult you DBA team to gain access to this code.

Good luck!

Editor's note: Do you agree with this expert's response? If you have more to share, post it in one of our .VO7aaqqaAFk.0@/search390>discussion forums.

Since the stored procedure needs to operate on several tables I need to know if a trigger can pass parameters. Potential parms would be table name, action taken (update/delete/etc...), column changed with before and after value, etc. Although I have used DB2 for several years, triggers and stored procedures are new for me. We recently converted to DB2v7, approximately eight months ago. Do you know where I could find examples of this? I have started looking at the DB2 Developers Guide, 4th ed.

Dig Deeper on IBM DB2 management

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.