[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Using triggers to send a message in DB2

Posted on 2012-09-17
Medium Priority
Last Modified: 2012-09-17
Hi all,

I need to send some sort of notification to a process running on the same box on insert or update.
I don't know if it's possible in DB2 itself?
If it is, what are the options?
Can I invoke some external program, or can it be done in some kind of embedded fashion?
No java - C/C++ only

Thank you
Question by:darrgyas
  • 3
  • 3
LVL 37

Expert Comment

ID: 38405042
you could have a trigger which calls an external program, but I'm not sure this is the best solution - depends on what you need.
If you need this to happen for every record does it have to be a synchronous call or can it be asynchronous?
if the latter, i would suggest having a program polling this specific table for new records (which can be identified by an ever increasing id of some type)
using a trigger will slow down all your updates and inserts

Author Comment

ID: 38405054
This is a small table, probably no more than 5-10 inserts a minute.
Some of the records will call for an immediate action, so
I need to have a synchronous notification
LVL 37

Assisted Solution

momi_sabag earned 750 total points
ID: 38405065
so you can do that but remember that the transaction is not committed until the external program is done
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.


Author Comment

ID: 38405070
Thank you for the warning - still have to do it that way. How?
LVL 37

Expert Comment

ID: 38405087
it depends on which platform of db2 you are using and which version, but basically you will need to create an external stored procedure (which is just a wrapper to you c/c++ program) and then call that stored procedure from the trigger

Author Comment

ID: 38405135
I have DB2 9.74 Express-C (on windows)
I am looking for an example.
Do you have any links?

Accepted Solution

mustaccio earned 750 total points
ID: 38406069
Documentation: http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.routines.doc/doc/t0020586.html

Code samples can be found in the samples directory of your DB2 installation.

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question