Q
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.

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.

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.

This was last published in September 2003

Dig Deeper on IBM DB2 management

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchAWS

SearchContentManagement

SearchOracle

SearchSAP

SearchSQLServer

Close