1

I'm trying to invoke some C++ code in case a trigger is called inside my db2 DB. to do so i thought of compiling the C++ code to an executable and to run it as a system call from DB2.

ps: I'm new to DB in general.

thanks in advance !

1 Answer 1

2

I think you want to use a DB2 system call:

http://www.ibm.com/developerworks/data/library/techarticle/0303stolze/0303stolze.html

EDIT: Specifically, it appears that you could just re-use the system call solution referenced in the "Making system calls" section to call an arbitrary command from your trigger:

http://www.ibm.com/developerworks/data/library/techarticle/0303stolze/0303stolze.html#section5

Generally, the from the docs I gather that you will need to call an external UDF (User Defined Function) from your trigger. The UDF itself defines the call to your external program and needs to be created and configured in such a way that DB2 will recognize it.

Here's a PDF that covers UDFs is some detail. The "External UDFs" section on page 453 might be useful.

http://www.redbooks.ibm.com/redbooks/pdfs/sg246503.pdf

This article may also be helpful. It shows a solution for integrating a Java function as a UDF to be called from a trigger.

http://www.ibm.com/developerworks/data/library/techarticle/0205bhogal/0205bhogal.html#download

3
  • thanks for the quick response. what should i do in case i need a trigger that when it is activated, it shall run a given executable (not a system call) with some changing parameters ?
    – anton
    Commented Nov 13, 2011 at 13:22
  • Glad to help. I think the link actually has the information you're after. I'll update the answer with more detail.
    – bigendian
    Commented Nov 13, 2011 at 16:25
  • thanks, that was exactly what i was trying to do, just that i got stuck on the part where i needed to install DB2 Application Development Client. how can i get it?
    – anton
    Commented Nov 14, 2011 at 7:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.